2015-02-14 01:12 AM
Hi there , I wrote a simple program that turns on the LED on the stmf4 discovery and using BlueTerm for sending data to the hc-05 module , the interrupt function is like this:
void USART1_IRQHandler(void){
// check if the USART1 receive interrupt flag was set
if( USART_GetITStatus(USART1, USART_IT_RXNE) ){ while(USART_GetITStatus(USART1, USART_IT_RXNE) == RESET);// Wait for Char
char o = ''o''; char t = USART1->DR;// the character from the USART1 data register is saved in t
if (strcmp(o,t) == 0) { GPIOD->BSRRL = (1 << 12); USART_puts(USART1, ''LED ON!rn''); } else{ GPIOD->BSRRH = (1 << 12); USART_puts(USART1, ''LED OFF!rn''); } }}This works(turns on the LED)BUT when I send ''
d''not ''
o''!!
It also works for ''y'' and some other letters.
Moreover when i tried to send back what the stm was reading (which is supposed to be ''d'' in this case) with something like this:..if (strcmp(o,t) == 0) {
GPIOD->BSRRL = (1 << 12);
USART_puts(USART1, t);
..I was getting 5 on my phone's Blueterm screen instead of a ''d''any idea why it's not responding to ''o'' in the first place and why it's sending back ''d'' as a ''5'' ??Thank you !!