This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can not configure NFC pins as GPIO to TOGGLE pin with TIMER1 using the freeRTOS demo

Hi, 

I'm working on a project that is using the the freeRTOS and I want to use the NFC pins P0.9 P0.10 to drive SOFTWARE SERIAL UART with a timer like TIMER1, when I try to toggle the signal the pin does no change at all to HIGH or LOW but if I run the same timer without the freeRTOS demo the pin can toggle just fine an therefore I can send data, could this be that the freeRTOS is already using the TIMER1 so it breaks my ISR routine, or is the freeRTOS messing with the CONFIG_NFCT_PINS_AS_GPIO configuration?

For example if I test a simple toggle on the pins using freeRTOS this will not toggle the pin 9:

#include "sdk_config.h"
#include "sdk_errors.h"
#include "nordic_common.h"
#include "nrf.h"
#include "nrf_delay.h"
#include "nrf_drv_clock.h"
#include "nrf_drv_gpiote.h"
#include "nrf_gpio.h"
#include "nrf_gpiote.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
#include "timers.h"

static TaskHandle_t m_task_thread;
static void Task(void *arg) {
    nrf_gpio_cfg_output(9);
    while (1) {
        vTaskDelay(100);
        nrf_gpio_pin_toggle(9);
    }
}

int main(void) {
    ret_code_t err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    if (pdPASS != xTaskCreate(Task, "TASK", 384, NULL, 2, &m_task_thread)) {
        APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
    }
    // Start FreeRTOS scheduler.
    vTaskStartScheduler();
    while (1) {
        APP_ERROR_HANDLER(NRF_ERROR_FORBIDDEN);
    }
}

but if I do the same as a super loop instead of using a freeRTOS task this will work as expected:

#include "sdk_config.h"
#include "sdk_errors.h"
#include "nordic_common.h"
#include "nrf.h"
#include "nrf_delay.h"
#include "nrf_drv_clock.h"
#include "nrf_drv_gpiote.h"
#include "nrf_gpio.h"
#include "nrf_gpiote.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "task.h"
#include "timers.h"

int main(void) {

    nrf_gpio_cfg_output(9);
    while (1) {
        nrf_delay_ms(100);
        nrf_gpio_pin_toggle(9);
    }

}

Regards, Frank

Related