Thread not getting executed!

05 Jun 2013

I have some bitmaps uploaded on the uC and the thing is as soon as I display the 7th bitmap on screen the thread is not created and the thread code does not execute at all! <<code>>display.FullScreenBMP(brew1);<</code>> this is the culprit as soon as I add it the LCD_thread does not execute!! what could be the case?

#include "mbed.h"
#include "KS0108.h"
#include "Arial12.h"
#include "SystemFont5x7.h"
#include "image.h"
#include "brew.h"
#include "rtos.h"
#include "menu_stop.h"
#include "menu_alert.h"
#include "menu_status.h"
#include "menu_realview.h"
#include "menu_temp.h"
#include "ReceiverIR.h"


// KS0108 (PinName _RST,PinName _DI, PinName _RW, PinName _E, PinName _CS1, PinName _CS2, PinName DB0, PinName DB1, PinName DB2, PinName DB3, PinName DB4, PinName DB5, PinName DB6, PinName DB7);

KS0108  display(PTC3,PTD6, PTE31, PTA17, PTC5, PTC4, PTA16, PTC17, PTC16, PTC13, PTC12, PTC11, PTC10, PTC6);
ReceiverIR ir_rx(PTA13);
Serial pc(USBTX, USBRX); // tx, rx
bool menu_alert = false, menu_realview = false, menu_status = false, menu_temp = false, menu_stop = false, HERMSbrew = false;
uint8_t buf[16];

void LCD_thread(void const *args)
{
    while (true) {
        display.FullScreenBMP(Menu_trial_startbut_Stop);
        Thread::wait(2);
        display.FullScreenBMP(Menu_trial_startbut_Temp);
        Thread::wait(2);
        display.FullScreenBMP(Menu_trial_startbut_RealTimeView);
        Thread::wait(2);
        display.FullScreenBMP(Menu_trial_startbut_Alert);
        Thread::wait(2);
        display.FullScreenBMP(Menu_trial_startbut_Status);
        Thread::wait(2);
        if(menu_alert){
        
        }else if(menu_realview){
        
        }else if(menu_status){
        
        }else if(menu_temp){
        
        }else if(menu_stop){
        
        }
    }
}

void led3_thread(void const *args)
{
    while (true) {

        //Thread::wait(0.5);
    }
}
int main()
{
    display.ClearScreen();
    display.FullScreenBMP(pic);
    wait(2);
    display.FullScreenBMP(brew1);
    wait(2);
    Thread thread(LCD_thread);
    Thread thread1(led3_thread);
    HERMSbrew = true;
    RemoteIR::Format format;
    memset(buf, 0x00, sizeof(buf));
    while(1) {
        if (ir_rx.getState() == ReceiverIR::Received) {
            ir_rx.getData(&format, buf, sizeof(buf) * 8);
            pc.printf("\n\rgot>> ");
            //for (int i=0; i<sizeof(buf); i++) {
            pc.printf("0x%02X, ", buf[0]);
            //pc.printf("%i",i);
            //}
            switch (format) {
                case RemoteIR::UNKNOWN:
                    pc.printf("????");
                    break;
                case RemoteIR::NEC:
                    pc.printf("NEC");
                    break;
                case RemoteIR::AEHA:
                    pc.printf("AEHA");
                    break;
                case RemoteIR::SONY:
                    pc.printf("SONY");
                    break;
            }
        }

    }

}

05 Jun 2013

I removed the second thread and now its fine!working as it should work

05 Jun 2013

Does this means the Threads arent supported yet on the KL25z I tried the RTOS with the LED flashing and it worked really fine and this the working code with RTOS:

#include "mbed.h"
#include "rtos.h"
 
DigitalOut led1(PTC7);
DigitalOut led2(PTC0);
DigitalOut led3(PTC3);
 
void led2_thread(void const *args) {
    while (true) {
        led2 = !led2;
        Thread::wait(1000);
    }
}

void led3_thread(void const *args){
    while (true) {
        led3 = !led3;
        Thread::wait(500);
    }
}
 
int main() {
    Thread thread(led2_thread);
    Thread thread1(led3_thread);
    
    while (true) {
        led1 = !led1;
        Thread::wait(100);
    }
}

07 Jun 2013

As soon I remove this

<<code>> display.FullScreenBMP(pic); wait(2); display.FullScreenBMP(brew1); wait(2); <</code>>

the thread and all stuff works, so is it the GLCD library not working?

07 Jun 2013

Anyone please?

07 Jun 2013

I have no KL25, not that display and also no experience with RTOS, so I can't help much. However I do know many (read: most) libraries aren't tested to work with RTOS. In practise that won't be a problem for the majority, but some could have problems.

Your second thread without a Thread::wait in it, can't that lockup? Where do you define pic and brew1? Do they have the correct size?

07 Jun 2013

I have tried eliminating the wait also, yes pic and brew1 are all fine! their size is fine, its only with threads they clash