cancel
Showing results for 
Search instead for 
Did you mean: 

UART2_RX_IRQHandler

spiovan9
Associate II
Posted on June 30, 2010 at 18:38

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

&sharpdefine NUM_CMD 2 // Length of the command string example M1, M2 etc.

&sharpifdef _COSMIC_

@far @interrupt void UART2_RX_IRQHandler(void)

&sharpelse /* _RAISONANCE_ */

void UART2_RX_IRQHandler(void) interrupt 21

&sharpendif /* _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;

}&sharpendif /* STM8S105*/

0690X00000603OFQAY.jpg

#irq #rs232 #uart
0 REPLIES 0