million in the six months ended September 30, 2021 to $6.9 million in the six months ended September 30, 2022. Cost of revenues included a provision for excess and obsolete inventories of $265,000 in the six months ended September 30, 2021 compared to $89,000 in the six months ended September 30, 2022. Cost of revenues included stock-based compensation expense of $64,000 and $49,000 for the three months ended September 30, 2021and 2022, respectively, and $134,000 and $109,000 for the six months ended September 30, 2021 and 2022, respectively.
Gross Profit. Gross profit increased by 34.1% from $4.2 million in the three months ended September 30, 2021 to $5.6 million in the three months ended September 30, 2022 and by 22.4% from $9.0 million in the six months ended September 30, 2021 to $11.0 million in the six months ended September 30, 2022. Gross margin increased from 53.6% in the three months ended September 30, 2021 to 62.6% in the three months ended September 30, 2022 and increased from 54.0% in the six months ended September 30, 2021 to 61.4% in the six months ended September 30, 2022. The changes in gross profit are primarily related to the increases in net revenues discussed above. The changes in gross margin are primarily related to changes in the mix of products and customers. Gross margin in the three months and six months ended September 30, 2022 reflect shipments of our radiation hardened SRAMs which typically have gross margins in excess of our overall average corporate gross margins.
Research and Development Expenses. Research and development expenses increased by 8.3% from $5.9 million in the three months ended September 30, 2021 to $6.4 million in the three months ended September 30, 2022. The increase in research and development spending was primarily related to an increase of $301,000 in outside consulting expenses for the development of our next generation APU product and an increase of $171,000 in software maintenance expense which were partially offset by a lesser decrease payroll related expenses and stock-based compensation expense. Research and development expenses included stock-based compensation expense of $418,000 and $390,000 for the three months ended September 30, 2021 and 2022, respectively. Research and development expenses increased by 8.4% from $12.0 million in the six months ended September 30, 2021 to $13.0 million in the six months ended September 30, 2022. The increase in research and development spending was primarily related to increases of $818,000 in outside consulting expenses for the development of our next generation APU product and $328,000 in software maintenance expense which was partially offset by decreases in payroll related expenses and stock-based compensation expense. Research and development expenses included stock-based compensation expense of $888,000 and $741,000 for the six months ended September 30, 2021 and 2022, respectively.
Selling, General and Administrative Expenses. Selling, general and administrative expenses decreased by 13.4% from $2.8 million in the three months ended September 30, 2021 to $2.4 million in the three months ended September 30, 2022. This decline in expenses included a decrease of $413,000 in the value of contingent consideration in the three months ended September 30, 2022 compared to an increase of $22,000 in the quarter ended September 30, 2022. The change in contingent consideration was partially offset by an increase of $99,000 in independent sales representatives’ commissions. Selling, general and administrative expenses included stock-based compensation expense of $234,000 and $222,000 for the three months ended September 30, 2021 and 2022, respectively. Selling, general and administrative expenses decreased by 12.5% from $5.8 million in the six months ended September 30, 2021 to $5.1 million in the six months ended September 30, 2022. This decline in expenses included a decrease of $830,000 in the value of contingent consideration in the six months ended September 30, 2022 compared to an increase of $44,000 in the six months ended September 30, 2021. The change in contingent consideration was partially offset by an increase of $125,000 in legal fees and a lesser increase in independent sales representatives’ commissions. Selling, general and administrative expenses included stock-based compensation expense of $517,000 and $449,000 for the six months ended September 30, 2021 and 2022, respectively.
Interest Income and Other Expense, Net. Interest and other income, net increased by $22,000 from a net expense of $8,000 in the three months ended September 30, 2021 to income of $14,000 in the three months ended September 30, 2022. Interest income increased by $37,000 primarily due to higher interest rates received on our cash and short-term and long-term investments. Foreign exchange losses were $26,000 for the three months ended September 30, 2021 compared to $41,000 for the three months ended September 30, 2022. Interest and other income, net increased by $68,000 from an expense of $28,000 in the six months ended September 30, 2021 to income of $40,000 in the six months ended September 30, 2022. Interest income increased by $36,000 primarily due to higher interest rates received on our cash and short-term and long-term investments. Foreign exchange losses were $69,000 for the six months ended September 30, 2021 compared to $37,000 for the six months ended