PIC24 Support Libraries
Macros | Functions
pic24_uart.c File Reference
#include "pic24_clockfreq.h"
#include "pic24_uart.h"
#include "pic24_ports.h"
#include "pic24_unittest.h"
#include "pic24_delay.h"
#include "pic24_util.h"

Go to the source code of this file.

Macros

#define DEFAULT_BRGH1   DEFAULT_BRGH
 

Functions

void checkRxErrorUART1 (void)
 
void outChar1 (uint8_t u8_c)
 
uint8_t isCharReady1 (void)
 
uint8_t inChar1 (void)
 
void configUART1 (uint32_t u32_baudRate)
 

Detailed Description

UART support functions.

Interrupt-driven TX/RX
By default, the UART functions use polling for both RX and TX. Define the macro UARTx_TX_INTERRUPT (i.e., UART1_TX_INTERRUPT) in your project file if you want interrupt-driven TX for the UARTx (i.e., UART1) module. For interrupt-driven TX, macro UARTx_TX_FIFO_SIZE sets the TX software FIFO size (default 32), and UARTx_TX_INTERRUPT_PRIORITY sets the priority (default 1).
Define the macro UARTx_RX_INTERRUPT (i.e., UART1_RX_INTERRUPT) in your project file if you want interrupt-driven RX for the UARTx (i.e., UART1) module. For interrupt-driven RX, macro UARTx_RX_FIFO_SIZE sets the RX software FIFO size (default 32), and UARTx_RX_INTERRUPT_PRIORITY sets the priority (default 1).

Definition in file pic24_uart.c.

Macro Definition Documentation

◆ DEFAULT_BRGH1

#define DEFAULT_BRGH1   DEFAULT_BRGH

Chose a default BRGH for UART1, used by configUART1 to set up UART1.

Definition at line 234 of file pic24_uart.c.

Referenced by configUART1().

Function Documentation

◆ checkRxErrorUART1()

void checkRxErrorUART1 ( void  )

Check UART1 RX for error, call reportError() if error found.

Definition at line 70 of file pic24_uart.c.

Referenced by inChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ configUART1()

void configUART1 ( uint32_t  u32_baudRate)

Configure the UART. Settings chosen:

  • TX is on RP11
  • RX is on RP10
  • Format is 8 data bits, no parity, 1 stop bit
  • CTS, RTS, and BCLK not used
Parameters
u32_baudRateThe baud rate to use.

Definition at line 250 of file pic24_uart.c.

Referenced by configDefaultUART(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ inChar1()

uint8_t inChar1 ( void  )

Wait for a byte to be available from UART1 RX.

Returns
Character read from UART1 RX.

Definition at line 214 of file pic24_uart.c.

Referenced by inChar(), outChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ isCharReady1()

uint8_t isCharReady1 ( void  )

Return true if character is ready to be read

Definition at line 206 of file pic24_uart.c.

Referenced by isCharReady(), outChar1(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().

◆ outChar1()

void outChar1 ( uint8_t  u8_c)

Output u8_c to UART1 TX.

Parameters
u8_cCharacter to write

Definition at line 145 of file pic24_uart.c.

Referenced by checkRxErrorUART1(), outChar(), and WAIT_UNTIL_TRANSMIT_COMPLETE_UART1().