Hello Nakul,
Basically, you need to read data from UART by reading UARTx_D register once UARTx_S1[RDRF] field has been set. You can use a simplest method of sending to CAN module every incoming data from UART in UART RX interrupt (or maybe you prefer to save this data into a global buffer, then read data from this buffer and send it through CAN)
UART module has capability to send/receive up to 9-bit data and you can also use FIFO functionality (Available for UART0 and UART1 only), but, supposing you are using basic 8-bit data transfers and no FIFO functionality, you can save received characters by using Receiver Full Interrupt (UARTx_C2[RIE]), for example, interrupt routine should look like this (if using baremetal implementation):
void UART0_RX_TX_IRQHandler (void) {
/* RX data received ? */
if (UART0_S1 & UART_S1_RDRF_MASK) {
if (g_write_ptr > (RX_BUFFER_SIZE - 1)) {
/* Point to start buffer */
g_write_ptr = g_rx_buffer;
}
/* Save data into buffer */
*g_write_ptr++ = UART0_D;
}
}
So, in every UART RX interrupt, data from UART module will be saved in g_rx_buffer buffer (Be aware to enable UART interrupt in NVIC module as well).
Once you have available data ready to be sent (you will also need to add extra logic to handle next data to be read), you will need to follow transmit process that is shown in section 46.4.1 Transmit process from MK22's reference manual.
If you are using Kinetis SDK you can look to flexcan_network_example_twrk21f120m example that is located at: <KSD_1_3_PATH>\examples\twrk21f120m\driver_examples\flexcan\flexcan_network\ or this same example for KSDK 2.0: <SDK_2.0_MK22FX512xxx12>\boards\twrk21f120m\driver_examples\flexcan
Hope this can help you!
Best Regards,
Isaac