Create a thread of rtos, but it doesn't work!

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
waer_4412851
Level 1
Level 1

Hi,

I create a thread,but it doesn't work in ble_remote part of sdk20735B1,code as following,

(ble_remote.c)

#include "wiced_rtos.h"

wiced_thread_t * ir_led_thread;

wiced_queue_t * button_queue;

/* Thread function to control the LED */

void IrLedControl( uint32_t arg )

{

    uint8_t key_state;

    while(1)

    {

        WICED_BT_TRACE("IrLedControl wait\n");

        /* Wait for button press semaphore */

        wiced_rtos_pop_from_queue( button_queue, &key_state, WICED_WAIT_FOREVER );

        KeyMatrixHandle(key_state);

      

        WICED_BT_TRACE("IrLedControl\n");

    }

}

void bleremoteapp_create(void)

{

    uint8_t thread_init_result;

  

    WICED_BT_TRACE("bleremoteapp_create\n");

  

    /* Setup the semaphore */

    button_queue = wiced_rtos_create_queue();

    wiced_rtos_init_queue(button_queue, "queue", 1, 10);

    /* Start a thread to control LED blinking */

    ir_led_thread = wiced_rtos_create_thread();       // Get memory for the thread handle

    thread_init_result = wiced_rtos_init_thread(

                            ir_led_thread,                  // Thread handle

                            5,                // Priority

                            "LED Toggle",                   // Name

                            IrLedControl,                   // Function

                            1024,          // Stack

                            NULL );

  

    WICED_BT_TRACE("thread_init_result=%d\n", thread_init_result);  

static void KeyMatrixInterruptHandler(void* user_data, uint8_t value)

{

    uint8_t read_data;  

  

    read_data = KeyMatrixReadByte(INPORT_REG_ADDR);        //read inport register status

    WICED_BT_TRACE("KeyMatrixInterruptHandler read_data = %02x\n", read_data);

  

    key_state = read_data;

    wiced_rtos_push_to_queue( button_queue, &key_state, WICED_NO_WAIT );

}

1. the result of wiced_rtos_create_thread() is '0'

2.the KeyMatrixInterruptHandler() was executed, and the value of key_state is 0x7b

3.KeyMatrixHandle(key_state) can't be executed.

Is there setting error?

Looking forward to reply, thanks

0 Likes
1 Solution

Yes, I tried, and it still can not work. then I used timer instead recommended by Owen.

View solution in original post

0 Likes
4 Replies
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi,

Could you please try increasing the memory (buffer pool size ) and see the results?

Also please try increasing " .max_number_of_buffer_pools = " value (in wiced_bt_cfg_settings structure) to 5.

Please share the complete project to check.

Thanks,

Anjana

AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hi @waer_4412851​,

Did you try increasing the buffer pool size?

Regards,

Anjana

0 Likes

Yes, I tried, and it still can not work. then I used timer instead recommended by Owen.

0 Likes

Ok Sure, you can continue with the timer implementation if it serves the purpose.

You may share your project and steps to reproduce if you want us to check the rtos issue.

Regards,

Anjana

0 Likes