AnsweredAssumed Answered

UART2_RX_IRQHandler

Question asked by piovan.stefano on Jun 30, 2010

Dear friends,
I've implemented a sort of tiny PC datalogger via RS232 based on the Discovery board and an ST232 serial interface. It is only 2 ADC channels + 4 DIN + 4DOUT.
The sampling time is 15 ms but this is because of Windos Vista and not because of STM8 and communication (19200 baud is large enough).
To activate the DOUTs, I give a command to the STM8 which is 2 characters long: the first is a mnemonic like the char "M" followed by an unsigned int (u8) which is the output whic I want to activate.
The transmission from the PC application (VC++ 6.0) to Discovery is made char by char therefore I needed to manage the Discovery data reception using an IRQ handler which I'd like to attach in the following piece of code. Cut and paste it into the "stm8s_it.c" file.

It works fine.
Stefano


#define NUM_CMD 2 // Length of the command string example M1, M2 etc.



#ifdef _COSMIC_
@far @interrupt void UART2_RX_IRQHandler(void)
#else /* _RAISONANCE_ */

void UART2_RX_IRQHandler(void) interrupt 21
#endif /* _COSMIC_ */

{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/

 

if (UART2CmdReady == FALSE)
{
UART2_data[UART2DataNum] = (char)UART2->DR;
UART2DataNum++;
if (UART2DataNum >= NUM_CMD)
UART2CmdReady = TRUE;
}
return;

}#endif /* STM8S105*/


datalogger.JPG

Outcomes