UART with NRF24LE1
In this modern world we all are aware about USB. We all connect our Pen drives, memory card and other devices using USB. But have you ever thought what is it? Here is the answer; USB is a communication protocol by which two devices communicate with each other. In the same way, microcontroller also communicates with other devices like sensors or PC by using different communication protocols like USB, UART, and I2C.
Today our focus will be on using UART communication for NRF24LE1.
UART stands for Universal Asynchronous Receiver/Transmitter. It is a type of serial communication that uses two wires, one for transmission (Tx) and one for reception (Rx). It makes use of start and stop bits in the packet to indicate the start and end of the packet. We also have an option to use parity bit inside data to indicate error in the transmitted data. Before using UART we have to declare the transmission and reception speed known as baud rate. The most common baud rate is 9600 bps (bits per second).
The NRF module offers variety of baud rate starting from 600 bps up to 38400 bps. The NRF pin P0.3 is Tx and pin P0.4 is Rx.
For more features you can refer to the datasheet. Also, you may refer to our previous articles on UART with PC and NRF24LE1 for more help.
We will be using nrfsdk (software development kit) provided by Nordic Semiconductors Ltd. The communication will be established between NRF and PC by sending “Hello” to the PC.
Functions which are helpful for using UART are:
· hal_uart_init() – This function takes baud rate to be used.
· hal_uart_tx_complete() – Checks for the completion of transmission.
· Hal_uart_putchar() – This function takes character for transmission.
· hal_uart_chars_available() – Checks if a character has been received or not.
· hal_uart_getchar() – It returns received character.