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

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)));
}

Parents
  • 0
    •  Analog Employees 
    on Mar 29, 2018 12:48 PM over 3 years ago

    Hi,

    Here some example code I have done in the past which allows to export I/V/T ADC data in UART mode.

    This example code is Tx only, note that the ADuCM331 can only transmit or receive in UART mode, not both.

    In order to receive data you could used the interrupt capability on GPIO4 to interrupt the running transmissions to indicate that data is to be received.

    I hope this helps

    regards

    Holger

Reply
  • 0
    •  Analog Employees 
    on Mar 29, 2018 12:48 PM over 3 years ago

    Hi,

    Here some example code I have done in the past which allows to export I/V/T ADC data in UART mode.

    This example code is Tx only, note that the ADuCM331 can only transmit or receive in UART mode, not both.

    In order to receive data you could used the interrupt capability on GPIO4 to interrupt the running transmissions to indicate that data is to be received.

    I hope this helps

    regards

    Holger

Children
No Data