We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everybody.I need to transmit through UART a fixed number in the data block through the command.I did this :void USART2_IRQHandler(void) { if ( USART_GetITStatus(USART2, USART_IT_RXNE) ) { USART_ClearITPendingBit(USART2, USART_IT_RXNE); RX_buffer[RX_write] = USART_ReceiveData(USART2); RX_write++; //chetchik ukazatel na massive RX_ct++;if (RX_ct == 9){if (RX_buffer[0] == 0x01) //ID{ID();}}}}void ID (uint8_t i) { while (!USART_GetFlagStatus(USART2, USART_SR_TXE)) {} USART_SendData(USART2,i=10);}But it's not working...
It's not terribly surprising that that code does not work. For starters, it's hardly ever a good idea to execute "wait until ... happens" loops inside an interrupt handler routine. Interrupt handlers are meant to be short. They need to be over quickly. Your design, which has a routine inside the interrupt handler quite likely trigger that very same interrupt handler, is even worse.
And let's hope that somewhere else, there is code to set RX_ct back to != 9, or you'll be sending out your answer for as long as Elvis remains dead.