Hi all, I´m trying to use safertos_demo to create an application that allows to run two task, the first one has to toggle a LED (when some condition active it, aperiodic task), the second one is a periodic task that read analog value and write the UART port, when it reads (analog data from ADC), it writes the data in UART port (periodic task), I´m trying to execute two task like periodic (LED and UART), and then, change (is as should be) LED periodic task into aperiodic task. I can do the analog reading using ADC and write it in UART port without safeRTOS, when I add the safeRTO the software donesn´t do anything. My code is attached.
//***************************************************************************** // // led_task.c - A simple flashing LED task. // // Copyright (c) 2009-2011 Texas Instruments Incorporated. All rights reserved. // Software License Agreement // // Texas Instruments (TI) is supplying this software for use solely and // exclusively on TI's microcontroller products. The software is owned by // TI and/or its suppliers, and is protected under applicable copyright // laws. You may not combine this software with "viral" open-source // software in order to form a larger program. // // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL // DAMAGES, FOR ANY REASON WHATSOEVER. // // This is part of revision 8049 of the DK-LM3S9D96 Firmware Package. // //***************************************************************************** #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #include "driverlib/rom.h" #include "SafeRTOS/SafeRTOS_API.h" #include "idle_task.h" #include "led_task.h" #include "priorities.h" //***************************************************************************** // // The stack for the LED toggle task. // //***************************************************************************** static unsigned long g_pulLEDTaskStack[128]; //***************************************************************************** // // The amount of time to delay between toggles of the LED. // //***************************************************************************** unsigned long g_ulLEDDelay = 500; //***************************************************************************** // // This task simply toggles the user LED at a 1 Hz rate. // //***************************************************************************** static void LEDTask(void *pvParameters) { portTickType ulLastTime; // // Get the current tick count. // ulLastTime = xTaskGetTickCount(); // // Loop forever. // while(1) { // // Turn on the user LED. // ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, GPIO_PIN_3); // // Wait for the required amount of time. // xTaskDelayUntil(&ulLastTime, g_ulLEDDelay); // // Turn off the user LED. // ROM_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_3, 0); // // Wait for the required amount of time. // xTaskDelayUntil(&ulLastTime, g_ulLEDDelay); } } //***************************************************************************** // // Initializes the LED task. // //***************************************************************************** unsigned long LEDTaskInit(void) { // // Initialize the GPIO used to drive the user LED. // ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); // // Create the LED task. // if(xTaskCreate(LEDTask, (signed portCHAR *)"LED", (signed portCHAR *)g_pulLEDTaskStack, sizeof(g_pulLEDTaskStack), NULL, PRIORITY_LED_TASK, NULL) != pdPASS) { return(1); } TaskCreated(); // // Success. // return(0); }
//***************************************************************************** // // uart_task.c - Task to output text on the UART. // // Copyright (c) 2009 Texas Instruments Incorporated. All rights reserved. // TI Information - Selective Disclosure // //***************************************************************************** #include "utils/uartstdio.h" #include "SafeRTOS/SafeRTOS_API.h" #include "uart_task.h" #include "priorities.h" #include "idle_task.h" #include "inc/hw_nvic.h" #include "inc/hw_ints.h" #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "grlib/grlib.h" #include "drivers/kitronix320x240x16_ssd2119_8bit.h" #include "drivers/set_pinout.h" #include "driverlib/gpio.h" #include "driverlib/uart.h" #include "driverlib/adc.h" #include "driverlib/interrupt.h" #include "driverlib/rom.h" #include "driverlib/sysctl.h" #include "driverlib/debug.h" #include "display_task.h" #include "idle_task.h" #include "led_task.h" #include "stdio.h" #include "utils/uartstdio.h" //***************************************************************************** // // This task receives messages from the other tasks and outputs strings to the // UART. // //***************************************************************************** //***************************************************************************** // // Variables globales para la aplicaci�n. // //***************************************************************************** float humedad, temperatura, datoSensor, Humedad1; char humidity[30]; char temperature[30]; char datoS[30]; unsigned long ulValue=0; unsigned char prueba; static void UARTTask(void *pvParameters) { // // Set the clocking to run directly from the crystal. // ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // // Set the device pinout appropriately for this board. // PinoutSet(); //configure PB4 for analog measurement SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0); GPIOPinTypeADC(GPIO_PORTB_BASE, GPIO_PIN_4); SysCtlADCSpeedSet(SYSCTL_ADCSPEED_125KSPS); ADCSequenceConfigure(ADC0_BASE,0, ADC_TRIGGER_PROCESSOR,0); ADCSequenceStepConfigure(ADC_BASE, 0, 0, ADC_CTL_CH10 | ADC_CTL_IE | ADC_CTL_END); ADCIntClear(ADC0_BASE, 0);//borro la interrupci�n de secuencia ADCSequenceEnable(ADC0_BASE, 0); ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); // // Enable processor interrupts. // IntMasterEnable(); // // Set GPIO A0 and A1 as UART pins. // ROM_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); // // Configure the UART for 115,200, 8-N-1 operation. // ROM_UARTConfigSetExpClk(UART0_BASE, ROM_SysCtlClockGet(), 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // // Enable the UART interrupt. // ROM_IntEnable(INT_UART0); ROM_UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT); while(1){ ADCProcessorTrigger(ADC0_BASE, 0); while(!ADCIntStatus(ADC0_BASE, 0,false)){ //Espero a que la conversi�n est� lista }; ADCSequenceDataGet(ADC0_BASE, 0, &ulValue);//Guardo los datos en el buffer &ulValue datoSensor = (float)ulValue; ulValue=ulValue*255/1023; prueba=ulValue; //prueba = 0x11; ROM_UARTCharPutNonBlocking(UART0_BASE, prueba); } } //***************************************************************************** // // Initializes the UART task. // //***************************************************************************** unsigned long UARTTaskInit(void) { // // Create the UART task. // if(xTaskCreate(UARTTask, (signed portCHAR *)"UART", (signed portCHAR *)UART0_BASE, sizeof(UART0_BASE), NULL, PRIORITY_UART_TASK,// LA PRIORIDAD DE LA UART ES 0 NULL) != pdPASS) { return(1); } TaskCreated(); // // Success. // return(0); }