Hi guys,
I have to admit that I am in the end of my forces.
I am using beaglebone white and I have problem with setting of baud rate in uart0. Bellow you can see all settings which I did. The very interesting thing is, that this settings working only with 115200 baudrate, if I was trying to set up different value, the communication was bad. For example: with 115200 I have got 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x65, which is correct. If I tried change baud rate to 230400 so I have got 0xFE 0xFE 0xFE 0xFE 0xFE 0xFE 0xFE 0xFE 0x66 and if I tried change the baud rate to 921600 I received something like 0x00 0x00 0x80 0x80 0x80 0x00 0x080...etc. Can you please help me with this problem? Thanks
void initUart ()
{
/* Configuring the system clocks for UART0 instance. */
UART0ModuleClkConfig ( );
/* Performing the Pin Multiplexing for UART0 instance. */
UARTPinMuxSetup ( 0 );
/* Performing a module reset. */
UARTModuleReset ( SOC_UART_0_REGS );
/* Performing FIFO configurations. */
UartFIFOConfigure ( );
/* Performing Baud Rate settings. */
UartBaudRateSet ( );
/* Switching to Configuration Mode B. */
UARTRegConfigModeEnable ( SOC_UART_0_REGS, UART_REG_CONFIG_MODE_B);
/* Programming the Line Characteristics. */
UARTLineCharacConfig ( SOC_UART_0_REGS, ( UART_FRAME_WORD_LENGTH_8 | UART_FRAME_NUM_STB_1 ),
UART_PARITY_NONE );
/* Disabling write access to Divisor Latches. */
UARTDivisorLatchDisable ( SOC_UART_0_REGS );
/* Disabling Break Control. */
UARTBreakCtl ( SOC_UART_0_REGS, UART_BREAK_COND_DISABLE );
/* Switching to UART16x operating mode. */
UARTOperatingModeSelect ( SOC_UART_0_REGS, UART16x_OPER_MODE );
/* Performing Interrupt configurations. */
UartInterruptEnable ( );
}
void UartFIFOConfigure ( void )
{
unsigned int fifoConfig = 0;
/* Setting the TX and RX FIFO Trigger levels as 1. No DMA enabled. */
fifoConfig = UART_FIFO_CONFIG(UART_TRIG_LVL_GRANULARITY_4,
UART_TRIG_LVL_GRANULARITY_1,
UART_FCR_TX_TRIG_LVL_56,
1,
1,
1,
UART_DMA_EN_PATH_SCR,
UART_DMA_MODE_0_ENABLE);
/* Configuring the FIFO settings. */
UARTFIFOConfig ( SOC_UART_0_REGS, fifoConfig );
}
void UartBaudRateSet ( void )
{
unsigned int divisorValue = 0;
/* Computing the Divisor Value. */
divisorValue = UARTDivisorValCompute ( UART_MODULE_INPUT_CLK, BAUD_RATE_115200,
UART16x_OPER_MODE, UART_MIR_OVERSAMPLING_RATE_42 );
/* Programming the Divisor Latches. */
UARTDivisorLatchWrite ( SOC_UART_0_REGS, divisorValue );
}
void UartInterruptEnable ( void )
{
/* Enabling IRQ in CPSR of ARM processor. */
IntMasterIRQEnable ( );
/* Configuring AINTC to receive UART0 interrupts. */
UART0AINTCConfigure ( );
/* Enabling the specified UART interrupts. */
UARTIntEnable ( SOC_UART_0_REGS, ( UART_INT_LINE_STAT | UART_INT_THR | UART_INT_RHR_CTI ) );
}
void UARTIsr ( void )
{
rxByte = 0;
unsigned int intId = 0;
/* Checking ths source of UART interrupt. */
intId = UARTIntIdentityGet ( SOC_UART_0_REGS );
switch ( intId )
{
case UART_INTID_TX_THRES_REACH:
/* Disabling the THR interrupt. */
UARTIntDisable ( SOC_UART_0_REGS, UART_INT_THR );
break;
case UART_INTID_RX_THRES_REACH:
rxByte = UARTCharGetNonBlocking ( SOC_UART_0_REGS );
/* Check for buffer overflow */
//assert ( rxCntr < RX_BUFFER_LENGTH );
/* Process incoming data */
//rxData[rxCntr++] = rxByte;
//tasks[IDX_SAVE_DATA].runFunc = TRUE;
break;
case UART_INTID_RX_LINE_STAT_ERROR:
case UART_INTID_CHAR_TIMEOUT:
rxCntr = 0;
rxByte = UARTCharGetNonBlocking ( SOC_UART_0_REGS );
//printf("%X ", rxByte);
break;
default:
break;
}
}
void UART0AINTCConfigure ( void )
{
/* Initializing the ARM Interrupt Controller. */
//IntAINTCInit ( );
/* Registering the Interrupt Service Routine(ISR). */
IntRegister ( SYS_INT_UART0INT, UARTIsr );
/* Setting the priority for the system interrupt in AINTC. */
IntPrioritySet ( SYS_INT_UART0INT, 0, AINTC_HOSTINT_ROUTE_IRQ );
/* Enabling the system interrupt in AINTC. */
IntSystemEnable ( SYS_INT_UART0INT );
}