Hallo
I do have some generel question when calling a function from a isr.
I do see some strange behavior when doing it, depending on compiler optimization level and code.
When calling a function from the isr, that do some float operation on some data, I get a data abort exception or a program abort exception. When running the same code with compiler optimization level 1, I get an spourios interrupt instead.?
But if I remove the floating point calculation in the function, I dont have any problems. (No exception or spurios interrupt)
I know its generally not a good idea to call function from ISR. I dont intend to do that. It just caught my attention why I get this strange behaviour? Has it something todo with calling non static function? I just would like to understand the reason...
See code sample below..
I dont use any Rtos. Im running on a LPC2103 and uVision 3.40
// ISR from the SPI.. void SPI_Isr(void) __irq { // Read the SPI status register if ((S0SPSR & 0xF8) == 0x80) { // Switch on state switch(bySPIState) { ... do stuff.... case 2: { .. reading SPI register ... // Store sample lConversionData[bChanl] = lTempConversion; // After a short time the exception occure // in the Update Update(); state = SPI_OK; // transfer completed } break; } } else // SPI error { .. error handling here state = SPI_ERROR; } // Reset SPI interrupt flag S0SPINT = 0x01; // ACK the interrupt VICVectAddr = 0; } void Update(void) { fTemp = (lConversionData[bChanl]&0xFFFFF) *0.001497268677; // mV fTemp = fTemp/150; // Is the sign bit set? if((lConversionData[bChanl]&0x200000) == 0x200000 ) // Signed? { fTemp *= -1; } protocol_UpdateData(WEIGHTCELL_MODULE, m_byCurrentChannel, fTemp, 0); }
So, if I move the code inside the Update() to the SPI isr, no problems!!
Calling the Update() i get the explained behaviour?
But I i just remove the "0.001497268677" value from the equation, no problemas?
If I remove the lConversionData[bChanl] no problems?
Why?
/Thomas