stancecoke wrote:Ok, I don't now the syntax to configure UART2 for interrupts. But that might solve the problem.
As it is written here, you have to catch some possible errors, too. I'm too frustrated to read through tons of literature at the moment...

Take a break
And let's see If I can help you:
Initialization:
Code: Select all
static void UART_Config(void)
{
UART2_DeInit();
UART2_Init((uint32_t)9600, UART2_WORDLENGTH_8D, UART2_STOPBITS_1, UART2_PARITY_NO,
UART2_MODE_TXRX_ENABLE);
UART2_ITConfig(UART2_IT_RXNE_OR, ENABLE);
enableInterrupts();
}
That was taken from the example code. I think should be easy for you to understand -- the news here is enabling the UART2_IT_RXNE_OR interrupt (Receive/Overrun interrupt).
And now the interrupt code, that you can use because you already did code for PAS interrupt, etc:
Code: Select all
INTERRUPT_HANDLER(UART2_RX_IRQHandler, 21)
{
/* Read one byte from the receive data register */
readed_byte = UART2_ReceiveData8();
- put readed_byte on a buffer
- if readed_byte_number == packet_size (Kunteng LCD is 13 bytes)
{
- flag_processing_LCC_data = 1;
- readed_byte_number = 0;
}
}
The idea is to read every byte an put on a buffer. But we should syncronize/find the start of a packet... on Kunteng, seems that last (or maybe we can consider to be the start package, depends on perspective

) 2 bytes are always "50 14" (e.g: 12 0 149 160 41 102 18 74 4 20 0 50 14). I would read them in sequence and then reset the readed_byte_number, knowing that next byte will be the 1st of the next package. In the end, the full package need to be verified against the CRC value.
-
EBike wireless standard: wireless motor, wireless cycling GPS display Garmin Edge and wireless remote with wireless brake sensor
-
TSDZ2 FAQ: issues and repairs, etc
-
TSDZ2 OpenSource firmware
Developer of OpenSource knowledge and technology for ebikes: Wireless EBike standard ANT+ and Bluetooth, TSDZ2 OpenSource firmware, KT motor controllers and displays: Bafang 850C color, SW102 Bluetooth and KT-LCD3.
Please consider a donation to help developments: paypal.me/jorgecasa