Hi All,
In the previous blog5 we have successfully brought the wireless communication between two mesh kits . And here we are going
to interface the MESH kit to XMC4200 via UART communication.
UART Interface:
UART example project is found under XMC4300 -> XMC_Peripheral_Library_v2.1.24\XMCLib\examples\XMC4500_series
We use the project (UART_TRANSMIT_RECEIVE_FIFO_INTERRUPTS) as a reference to port into XMC4200.
Key changes are baudrate value and PIN numbers
#define UART_TX P1_5 #define UART_RX P2_15 /* Initialization structure for both USIC0_CH0 and USIC0_CH1 channels */ XMC_UART_CH_CONFIG_t uart_config = { .data_bits = 8U, .stop_bits = 1U, .baudrate = 921600U //115200U };
I have used TX Pin as P1_5 , which is connected to JTAG debugger UART , Its helps in debugging and another pin P2_15 Rx pin connected
to the MESH kit TX pin P12.
I'm using the UART1 handler to read and process the data from Mesh kit.
/* Receive handling IRQ */ void USIC1_1_IRQHandler(void) { while(!XMC_USIC_CH_RXFIFO_IsEmpty(XMC_UART1_CH0)) { rx_data[rx_index] = XMC_UART_CH_GetReceivedData(XMC_UART1_CH0); }
These received data is filtered and processed to control the LED lights and PWM.
the data format is 0x00,0x00,0x00,0x00 4bytes (byte1 -> LED, byte2->motor, byte3->pwm_value, byte4->auto_timer)
Operation:
Two modes of operation here, one is user controlled from wireless remote and another mode is automatic. In automatic mode the
as per the scheduled time the MOTOR or LIGHT will be turned ON or OFF after timeout.
In the current setup,12V power supply is taken from the 7.5A battery connected to PROFET+2_12V Kit. 12V LED lights are used for now
to showcase the , for DC motor its required to build and 9V supply with 7809 regulator. Here is the working demo of controlling the 12V lights
from mesh remote.
In the next blog7 we going to do some improvements on the current setup.