Click here to Skip to main content
15,214,872 members
Rate this:
Please Sign up or sign in to vote.
Hello everybody.
I need to transmit through UART a fixed number in the data block through the command.

But it's not working...

What I have tried:

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 == 3)
        {
            if (RX_buffer[0] == 0x01) //ID
            {
                ID();
            }
        }
    }
}

void ID (uint8_t i) 
{
    while (!USART_GetFlagStatus(USART2, USART_SR_TXE))
    {
    }
    USART_SendData(USART2,i=10);
}
Posted
Updated 13-Apr-20 10:22am
v3
Comments
Rick York 13-Apr-20 16:27pm
   
Have you identified which part is not working?

You are calling five different USART functions from this IRQ handler so start from the beginning : is the handler getting called? Then verify each function call from there. Debuggers are useful for this kind of thing but I know they can be difficult in embedded environments so some kind of trace mechanism can help with this if printf-style debugging is an option.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100