Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
1.00/5 (1 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 :
C++
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900