hello,
I working on nrf52832. in that I am working in freeRTOS for example I am creating two tasks using a queue. but when I create the third task not able to run any debug processing I don't know the task is created or not. and I already increased the heap size from 4092 to 8192. but the same problem faced.
#include <stdint.h>
#include <string.h>
#include "nordic_common.h"
#include "nrf.h"
#include "app_error.h"
#include "ble.h"
#include "nrf_sdh_ble.h"
#include "nrf_sdh_freertos.h"
#include "FreeRTOS.h"
#include "task.h"
#include "timers.h"
#include "semphr.h"
#include "nrf_ble_qwr.h"
#include "nrf_log.h"
#include "nrf_log_ctrl.h"
#include "nrf_log_default_backends.h"
#define OSTIMER_WAIT_FOR_QUEUE 2 /**< Number of ticks to wait for the timer queue to be ready */
NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/
static TaskHandle_t m_sender_thread;
static TaskHandle_t m_receiver_thread; /**< Definition of Logger thread. */
static TaskHandle_t m_tx1_thread;
xQueueHandle Global_queue_Handle = 0;;
/**@brief Function for handling Queued Write Module errors.
*
* @details A pointer to this function will be passed to each service which may need to inform the
* application about an error.
*
* @param[in] nrf_error Error code containing information about what went wrong.
*/
static void nrf_qwr_error_handler(uint32_t nrf_error)
{
APP_ERROR_HANDLER(nrf_error);
}
/**@brief Function for initializing the nrf log module.
*/
static void log_init(void)
{
ret_code_t err_code = NRF_LOG_INIT(NULL);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEFAULT_BACKENDS_INIT();
}
static void tx1(void * arg){
UNUSED_PARAMETER(arg);
while (1)
{
NRF_LOG_INFO("task3");
}
}
static void sender_thread(void * arg)
{
UNUSED_PARAMETER(arg);
volatile int i = 0;
int rx = 0;
NRF_LOG_INFO("task 1 : %d",uxTaskGetStackHighWaterMark( &m_sender_thread ));
while (1)
{
i++;
xQueueReceive(Global_queue_Handle,&rx,2);
NRF_LOG_INFO("Received1 %d ",rx);
//NRF_LOG_INFO("send");
xQueueSend(Global_queue_Handle,&i,2);
NRF_LOG_INFO("send1 %d ",i);
NRF_LOG_FLUSH();
vTaskSuspend(NULL); // Suspend myself
}
}
static void receiver_thread(void * arg)
{
UNUSED_PARAMETER(arg);
volatile i = 100;
int rx = 0;
NRF_LOG_INFO("task 2 : %d",uxTaskGetStackHighWaterMark( &m_receiver_thread ));
while (1)
{
i--;
xQueueSend(Global_queue_Handle,&i,2);
NRF_LOG_INFO("send2 %d ",i);
xQueueReceive(Global_queue_Handle,&rx,2);
NRF_LOG_INFO("Received2 %d ",rx);
//vTaskDelay(10);
NRF_LOG_FLUSH();
vTaskSuspend(NULL); // Suspend myself
}
}
/**@brief A function which is hooked to idle task.
* @note Idle hook must be enabled in FreeRTOS configuration (configUSE_IDLE_HOOK).
*/
void vApplicationIdleHook( void )
{
vTaskResume(m_sender_thread);
vTaskResume(m_receiver_thread);
vTaskResume(m_tx1_thread);
}
/**@brief Function for initializing the clock.
*/
static void clock_init(void)
{
ret_code_t err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
}
/**@brief Function for application main entry.
*/
int main(void)
{
bool erase_bonds;
//clock_init();
// Initialize modules.
log_init();
// Do not start any interrupt that uses system functions before system initialisation.
// The best solution is to start the OS before any other initalisation.
Global_queue_Handle = xQueueCreate(3,sizeof(int));
// Start execution.
if (pdPASS != xTaskCreate(sender_thread, "sender", configMINIMAL_STACK_SIZE +300 , NULL, 1, &m_sender_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
NRF_LOG_INFO("NOT created1");
}
if (pdPASS != xTaskCreate(receiver_thread, "receiver", configMINIMAL_STACK_SIZE +300 , NULL, 1, &m_receiver_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
NRF_LOG_INFO("NOT created1");
}
//configSTACK_DEPTH_TYPE uxTaskGetStackHighWaterMark2( TaskHandle_t xTask );
if (pdPASS != xTaskCreate(tx1, "tx1", configMINIMAL_STACK_SIZE + 300, NULL, 1, &m_tx1_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
NRF_LOG_INFO("NOT created2");
}
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
NRF_LOG_INFO("testing FreeRTOS example started.");
// Start FreeRTOS scheduler.
vTaskStartScheduler();
for (;;)
{
//APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
}
}
OUTPUT ::
00> <info> app: testing FreeRTOS example started
only this much of print I got.
help me to fix these issues. thank you