how do I use the fifo correctelly?
I can count how many times the fifo interruption was called, but every 16bytes, the uart finishes the communication. The uart sends a \n character.
In my case, Im using the uart0 to the terminal and the uart1 with the serial to usb board.
It is really hard for me to figure out this alone.
Thank you!
Thiago
//********************************************************************
//-----------------------------VARIABLES------------------------------
//********************************************************************
volatile uint8_t input[] = "Teste";
volatile uint8_t output[256];
volatile uint32_t FIFOCount =0;
//********************************************************************
//------------------------FUNCTION PROTOTYPES-------------------------
//********************************************************************
void ConfigureUART0(void);
void ConfigureUART1(void);
void UART1IntHandler(void);
void UART0IntHandler(void);
void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer);
//********************************************************************
//-----------------------------INT MAIN-------------------------------
//********************************************************************
int main(void)
{
//
// Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL.
//
SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
// Configure the LED as an output and turn it on.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
//
// Set up the serial console to use for displaying messages.
//
ConfigureUART0();
//
//Initilize the Uart port to communicate with the XBee radio at port B0 and B1
//
ConfigureUART1();
//
//Enable interrupts to the processor
//
IntMasterEnable();
//UART_Transmit(UART0_BASE, (uint8_t *)"\n 7E000F1001000000000000FFFFFFFE0000549F\0");
//UART_Transmit(UART1_BASE, (uint8_t *)"7E 00 141001000000000000FFFFFFFE000054686961676F97\0");
UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");
while(1)
{
UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");
while(UARTBusy(UART1_BASE));
UART_Transmit(UART0_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");
while(UARTBusy(UART0_BASE));
SysCtlDelay(SysCtlClockGet() / 12);
}
}
//*******************************************************************************
//-----------------------CONFIGURATION FUNCTIONS---------------------------------
//*******************************************************************************
//*****************************************************************************
//
// This function sets up UART0 to be used for a console to display information
// as the example is running.
//
//*****************************************************************************
void ConfigureUART0(void)
{
//
// Enable GPIO port A which is used for UART0 pins.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
//
// Enable UART0
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
//
// Configure GPIO Pins for UART1 mode.
//
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Use the internal 16MHz oscillator as the UART clock source.
// Initialize the UART for console I/O.
//
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); //Add
UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
IntEnable(INT_UART0); //enable the UART interrupt
UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); //only enable RX and TX interrupts
UARTFIFOEnable(UART0_BASE);
}
//*****************************************************************************
// Configure the UART1 and pins PB0 - PB1
// This UART1 is used for the XBee Radio
//*****************************************************************************
void ConfigureUART1(void)
{
//
// Enable the GPIO Peripheral used by the UART1.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
//
// Enable UART1
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
//
// Configure GPIO Pins for UART1 mode.
//
GPIOPinConfigure(GPIO_PB0_U1RX);
GPIOPinConfigure(GPIO_PB1_U1TX);
GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
//
// Use the internal 16MHz oscillator as the UART clock source.
// Initialize the UART for console I/O.
//
UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
// IntMasterEnable(); //enable processor interrupts
IntEnable(INT_UART1); //enable the UART interrupt
UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
}
//*******************************************************************************
//-----------------------INTERRUPTION FUNCTIONS----------------------------------
//*******************************************************************************
// to receive from uart1
void UART0IntHandler(void)
{
uint32_t ui32Status, i;
ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
if(ui32Status & UART_INT_TX) {
FIFOCount++; //Add
}
// ui32Bytes = ui32UartMessage;
i = 0;
while(UARTCharsAvail(UART0_BASE)) //loop while there are chars
{
input[i++]= UARTCharGet(UART0_BASE);
}
}
// to receive from uart1
void UART1IntHandler(void)
{
uint32_t ui32Status, i;
ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status
UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts
i = 0;
while(UARTCharsAvail(UART1_BASE)) //loop while there are chars
{
//output[i++]= UARTCharGet(UART1_BASE);
UARTCharPut(UART0_BASE, UARTCharGet(UART1_BASE)); //echo character
}
}
void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer)
{
//
// Loop while there are more characters to send.
//
while(*pui8Buffer != '\0')
{
//
// Write the next character to the UART.
//
UARTCharPut(ui32UARTBase, *pui8Buffer++);
}
}
how do I use the fifo correctelly?Based on your code, I wrote this one.
I can count how many times the fifo interruption was called, but every 16bytes, the uart finishes the communication.
In my case, Im using the uart0 to the terminal and the uart1 with the serial to usb board.
It is really hard for me to figure out this alone.
Thank you!
Thiago
//********************************************************************//-----------------------------VARIABLES------------------------------//********************************************************************
volatile uint8_t input[] = "Teste";volatile uint8_t output[256];volatile uint32_t FIFOCount =0;//********************************************************************//------------------------FUNCTION PROTOTYPES-------------------------//********************************************************************void ConfigureUART0(void);void ConfigureUART1(void);void UART1IntHandler(void);void UART0IntHandler(void);void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer);
//********************************************************************//-----------------------------INT MAIN-------------------------------//********************************************************************int main(void){
// // Set the clocking to run at 20 MHz (200 MHz / 10) using the PLL. // SysCtlClockSet(SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_16MHZ);
// Configure the LED as an output and turn it on. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3 | GPIO_PIN_2 | GPIO_PIN_1);
// // Set up the serial console to use for displaying messages. // ConfigureUART0();
// //Initilize the Uart port to communicate with the XBee radio at port B0 and B1 // ConfigureUART1(); // //Enable interrupts to the processor // IntMasterEnable(); //UART_Transmit(UART0_BASE, (uint8_t *)"\n 7E000F1001000000000000FFFFFFFE0000549F\0"); //UART_Transmit(UART1_BASE, (uint8_t *)"7E 00 141001000000000000FFFFFFFE000054686961676F97\0"); UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0");
while(1) { UART_Transmit(UART1_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0"); while(UARTBusy(UART1_BASE));
UART_Transmit(UART0_BASE, (uint8_t *)"7E00141001000000000000FFFFFFFE000054686961676F97\0"); while(UARTBusy(UART0_BASE)); SysCtlDelay(SysCtlClockGet() / 12); }}
//*******************************************************************************//-----------------------CONFIGURATION FUNCTIONS---------------------------------//*******************************************************************************
//*****************************************************************************//// This function sets up UART0 to be used for a console to display information// as the example is running.////*****************************************************************************void ConfigureUART0(void){ // // Enable GPIO port A which is used for UART0 pins. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
// // Enable UART0 // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
// // Configure GPIO Pins for UART1 mode. // GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// // Use the internal 16MHz oscillator as the UART clock source. // Initialize the UART for console I/O. // UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8); //Add
UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_FIFO);
IntEnable(INT_UART0); //enable the UART interrupt UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); //only enable RX and TX interrupts UARTFIFOEnable(UART0_BASE);}
//*****************************************************************************// Configure the UART1 and pins PB0 - PB1// This UART1 is used for the XBee Radio//*****************************************************************************void ConfigureUART1(void){ // // Enable the GPIO Peripheral used by the UART1. // SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
// // Enable UART1 // SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);
// // Configure GPIO Pins for UART1 mode. // GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
// // Use the internal 16MHz oscillator as the UART clock source. // Initialize the UART for console I/O. // UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
// IntMasterEnable(); //enable processor interrupts IntEnable(INT_UART1); //enable the UART interrupt UARTIntEnable(UART1_BASE, UART_INT_RX | UART_INT_RT); //only enable RX and TX interrupts
}
//*******************************************************************************//-----------------------INTERRUPTION FUNCTIONS----------------------------------//*******************************************************************************
// to receive from uart1void UART0IntHandler(void){ uint32_t ui32Status, i;
ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status
UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts
if(ui32Status & UART_INT_TX) {
FIFOCount++; //Add
}
// ui32Bytes = ui32UartMessage; i = 0;
while(UARTCharsAvail(UART0_BASE)) //loop while there are chars { input[i++]= UARTCharGet(UART0_BASE);
}}
// to receive from uart1void UART1IntHandler(void){ uint32_t ui32Status, i;
ui32Status = UARTIntStatus(UART1_BASE, true); //get interrupt status
UARTIntClear(UART1_BASE, ui32Status); //clear the asserted interrupts i = 0;
while(UARTCharsAvail(UART1_BASE)) //loop while there are chars { //output[i++]= UARTCharGet(UART1_BASE); UARTCharPut(UART0_BASE, UARTCharGet(UART1_BASE)); //echo character
}}
void UART_Transmit(uint32_t ui32UARTBase, const uint8_t *pui8Buffer){ // // Loop while there are more characters to send. // while(*pui8Buffer != '\0') { // // Write the next character to the UART. // UARTCharPut(ui32UARTBase, *pui8Buffer++); }}