Other Parts Discussed in Thread: SYSCONFIG
Dear Expert.
Customer try to write a program for dual LIN TX.
LIN1(B9/A9) & LIN2 (A8/B8) use same baud rate (19200) to shoot same 6 bytes data. Even we declare same baud rate parameter in code, but we found LIN1 & LIN2 is still base on different baud rate (clock) for data transmission. We not sure what's something wrong.
Capture graph as below,
The clock is not the same obviously!
(1) LIN 1, 19200, 2.5ms/DIV
(2) LIN2, 19200 ?!, 2.5ms/DIV
(2) LIN2, 19200 ?!, 500us/DIV
Code as below.
LIN1:
#define FRAME_LENGTH (0x8)
#define LIN_ID (0x10)
#define LIN_PASS (0xABCD)
#define LIN_FAIL (0xFFFF)
#define APP_LIN1_BASE_ADDR (CONFIG_LIN1_BASE_ADDR)
#define APP_LIN2_BASE_ADDR (CONFIG_LIN2_BASE_ADDR)
/* Globals */
uint16_t result;
uint16_t txData[8] = {0x12, 0x34, 0x56, 0x78, 0x9A, 0xAB, 0xCD, 0xEF};
uint16_t txxData[8] = {0x00, 0xFF, 0x55, 0xAA, 0xFF, 0x00, 0xAA, 0x55};
uint16_t rxData[8] = {0x00};
/* lin_external_main */
void lin1_tx_test(void)
{
uint32_t i;
uint16_t txID, error = 0;
int32_t status;
uint8_t txBuffer[1];
/* Open drivers to open the UART driver for console */
ti_Console_print("[LIN1] LIN mode external, application started ...\r\n");
/* Enable parity check */
LIN_enableParity(APP_LIN1_BASE_ADDR);
/* Enable multi-buffer mode */
LIN_enableMultibufferMode(APP_LIN1_BASE_ADDR);
/* Enable Fixed baud rate mode */
LIN_disableAutomaticBaudrate(APP_LIN1_BASE_ADDR);
/* Reaching the Baud of 19200 */
LIN_setBaudRatePrescaler(APP_LIN1_BASE_ADDR, 624U, 0U);
/* Enable transfer of data to the shift registers */
LIN_enableDataTransmitter(APP_LIN1_BASE_ADDR);
/* Enable the triggering of checksum compare on extended frames */
LIN_triggerChecksumCompare(APP_LIN1_BASE_ADDR);
ti_Console_print("LIN1 Volatage Level Shifter started ...\r\n");
/*
* Perform 8 data transmissions with different transmit IDs and varying
* number of bytes transmitted. Received data is checked for correctness.
*/
// for(i = 1 ; i <= FRAME_LENGTH; i++)
// {
i = 6;
/* Create a new transmit ID and update with parity bits */
txID = (LIN_ID + i);
txID = LIN_generateParityID(txID);
/*
* Set the frame length (number of bytes to be transmitted)
*/
LIN_setFrameLength(APP_LIN1_BASE_ADDR, i);
/*
* This places data into the transmit buffer.
* No ID or data is placed on the bus and transmitted yet.
*/
LIN_sendData(APP_LIN1_BASE_ADDR, txxData);
/*
* Set the message ID to initiate a header transmission.
* This causes the ID to be written to the bus followed by the
* data in the transmit buffers.
*/
LIN_setIDByte(APP_LIN1_BASE_ADDR, txID);
ti_Console_print("[LIN1] : New Data Sent = %x\r\n", txxData[i-1]);
// }
}
LIN2:
void lin2_tx_test(void)
{
uint32_t i;
uint16_t txID, error = 0;
int32_t status;
uint8_t txBuffer[1];
/* Open drivers to open the UART driver for console */
ti_Console_print("[LIN2] LIN mode external, application started ...\r\n");
/* Enable parity check */
LIN_enableParity(APP_LIN2_BASE_ADDR);
/* Enable multi-buffer mode */
LIN_enableMultibufferMode(APP_LIN2_BASE_ADDR);
/* Enable Fixed baud rate mode */
LIN_disableAutomaticBaudrate(APP_LIN2_BASE_ADDR);
/* Reaching the Baud of 19200 */
LIN_setBaudRatePrescaler(APP_LIN2_BASE_ADDR, 624U, 0U);
/* Enable transfer of data to the shift registers */
LIN_enableDataTransmitter(APP_LIN2_BASE_ADDR);
/* Enable the triggering of checksum compare on extended frames */
LIN_triggerChecksumCompare(APP_LIN2_BASE_ADDR);
ti_Console_print("LIN2 Volatage Level Shifter started ...\r\n");
/*
* Perform 8 data transmissions with different transmit IDs and varying
* number of bytes transmitted. Received data is checked for correctness.
*/
// for(i = 1 ; i <= FRAME_LENGTH; i++)
// {
i = 6;
/* Create a new transmit ID and update with parity bits */
txID = (LIN_ID + i);
txID = LIN_generateParityID(txID);
/*
* Set the frame length (number of bytes to be transmitted)
*/
LIN_setFrameLength(APP_LIN2_BASE_ADDR, i);
/*
* This places data into the transmit buffer.
* No ID or data is placed on the bus and transmitted yet.
*/
LIN_sendData(APP_LIN2_BASE_ADDR, txxData);
/*
* Set the message ID to initiate a header transmission.
* This causes the ID to be written to the bus followed by the
* data in the transmit buffers.
*/
LIN_setIDByte(APP_LIN2_BASE_ADDR, txID);
ti_Console_print("[LIN2] : New Data Sent = %x\r\n", txxData[i-1]);
// }
}
Do I miss something? Need suggestion~
Many Thanks
Gibbs