UART SCB example project with RX interrupts

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I was looking into UART communication and was able to send and receive data by connecting UART RX and TX pins with help of example code below:

   

 

   

int main()
{
    uint8 ch;

   

    /* Start SCB (UART mode) operation */
    UART_Start();
    UART_UartPutChar(48);
    for (;;)
    {
        ch = UART_UartGetChar();

   

        if (0 != ch)
        {
            UART_UartPutChar(ch);
        }
    }
}

   

 

   

Is there any example code online where I can find how to use interrupt for RX or any documentation for APIs.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest way: let the component handle the interrupts. Set the Rx and Tx buffer sizes to 80. You can question the number of chars received using SCB_SpiUartGetRxBufferSize() which returns the number of bytes in the buffer, not the size.

   

internal clock for SCB, I can't change the baud rate   That's not right, you can select a baud rate from the drop-down list or even type a number. External clock is meant extern to the component, connect a clock component to the terminal.

   

 

   

Bob

View solution in original post

0 Likes
6 Replies
Anonymous
Not applicable

Important : I need SCB example / APIs

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Just right click on your component and select "Find Example Project"

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks for the help. I found the example code and it doesn't have the interrupt routine, but after reading component datasheet I have plenty of information for setting interrupts on RX and TX pins.

   

Another question: As far as I can read/find if I use internal clock for SCB, I can't change the baud rate so I need to use external clock. My question is, does "External clock" means clock from terminal where I provide clock using drag and drop ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Easiest way: let the component handle the interrupts. Set the Rx and Tx buffer sizes to 80. You can question the number of chars received using SCB_SpiUartGetRxBufferSize() which returns the number of bytes in the buffer, not the size.

   

internal clock for SCB, I can't change the baud rate   That's not right, you can select a baud rate from the drop-down list or even type a number. External clock is meant extern to the component, connect a clock component to the terminal.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Easiest way: let the component handle the interrupts. Set the Rx and Tx buffer sizes to 80. You can question the number of chars received using SCB_SpiUartGetRxBufferSize() which returns the number of bytes in the buffer, not the size.

   

I will look into it. Seems cleanest way.

   

 External clock is meant extern to the component, connect a clock component to the terminal.

   

My bad. I meant terminal. I was going through your thread http://www.cypress.com/forum/psoc-3-device-programming/can-i-change-uart-baud-rate-run-time and downloaded your project as well, I have some questions

   

1) Why 1.843 ?

   

2) How you find out which divider is for which baud rate ? 

   

3) Is baud rate generated by divider reliable ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your link is a 404

   

1) don't know the context of that number

   

2) using internal clock and looking at the generated clock values

   

3) That depends on the clock accuracy, normally that works flawlessly. When talking to a device with stronger requirements a crystal or external precision clock might be needed.

   

 

   

Bob

0 Likes