AnsweredAssumed Answered

How to use ADUCM330/331 UART mode to TX and RX data

Question asked by VincentDeng on Nov 15, 2017
Latest reply on Mar 29, 2018 by Holger

Hi, it shows that the LIN module in ADUCM330/331 support UART mode, so I want to use this mode to communication with DB9 of my computer.

But in the examples, there is no demo project about UART mode. So I write a project based on user manual, but fail to TX and RX data. When I debug my project, I found that LINCON always 0x100, and LINBR is always 0x326.

Does anyone have UART example project?

 

My part of code is shown as below. The whole project is attached as well.


int main(void)
{
T3CON = 0;
ISER0 = 0x720;
HSI_GpioConfig();
HSI_UartInit();
SysTick_Config(SYSTEM_TICK_0_25_MS);
ADC_CFG(0x3);
ADC_Start();

while(1)
{
TSK_TaskHandler();
}
}


void HSI_UartInit(void)
{
unsigned int HVstatus;
/* TX and RX pins are configured in HSI_GpioConfig() */
LINCON = ( (1u << 12u) |
(1u << 6u ) ); /* enable UART mode */
LINIMSK = 0u; /* enable all interrupts by clear mask bit */
LINBR = UART_BAUD_RATE_57600; /* UART baud rate-->284u = 16384000 / 57600*/

/* send a special byte to test UART work or not */
HSI_UartSendByte(0xAB);
}


void HSI_UartSendByte(uint8_t byte)
{
/* fill the data into TX buf */
LINCON |= 0x40u; /* enable UART mode again */
LIND1 = byte;

/* wait last byte is tx complete */
//while(!(LINSTA & (1u << 11u)));
}

Outcomes