Application Perepherals Configured
1. Serial1.
2. Serial2.
3. Serial3.
4. SPI2.
5. ADC0 - Only 1 pin.
6. Some GPIO's for LEDs.
UART1 : Device A
UART2 : Console
UART3 : Device B
The Peripheral code (read/write) for Serial1 & Serial3 works fine Individually (If ran one after the other from the Console).
Now in our application we need Serial1 & Serial3 running in parallel.
Now when I put the two ( Serial 1 & Serial 3) Rx in different threads, Only one works fine, the other doesn't work( Hangs ).
The freezing happens on a specific point ( Thread 3 after sending the 4th Command to the module ) where the device has to read from the Module.
When the module is used individually it works fine without any freezing or getting stuck but when its used in a thread it doesn't pass the 4th command ( commands are AT Commands working fine if ran individually).
I increased the stack sizes to 8192 for All three Threads. It works for a while and then goes in Unhandled Exception Code.
Thread Summary
Thread 1 : Blinking LED as per the FATFS Demo Code.
Thread 2 : Obtain Serial1's data via AsyncRead ( infinite loop).
Thread 3 : Confugure the Serial3 Device & Read The Output ( infinite loop).
Thread Creation
Code: Select all
//In Main
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
chThdCreateStatic(waThread3, sizeof(waThread3), NORMALPRIO, Thread3, NULL);Code: Select all
static msg_t Thread3(void *arg) {
(void)arg;
chRegSetThreadName("redpine");
chprintf(&SD2,"Starting Redpine in 5 secs\r\n");
chThdSleepMilliseconds(5000);
redpine_process(); //Inidialize Code
chprintf(&SD2,"Redpine Setup Done Going to Decompose\r\n");
decompose_redpine();
//Never Reaches Here
return 0;
}Code: Select all
static msg_t Thread2(void *arg)
{
//(void)arg;
chRegSetThreadName("read_gps");
gps_read(); //FUnction Outputs on Serial2 Latitude,Longitude
//Never Reaches Here
return 0;
}