Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


ADC interfacing using RTOS on PIC24FJ

Posted by Shashank on April 4, 2013
Hello Everyone!!
I am trying to interface 12, 10 bit-ADC on PIC24FJ256GB210. I successfully ported the RTOS on the same controller and verified it by blinking 2 LEDs in to two task with a delay of 200 ms and 400 ms. The code which I wrote was like this:
void vTask1( void *pvParameters )
for( ;; )
LATDbits.LATD8 = ~LATDbits.LATD8;
vTaskDelay( 2000 / portTICK_RATE_MS );
void vTask2( void *pvParameters )
for( ;; )
LATDbits.LATD9 = ~LATDbits.LATD9;
vTaskDelay( 4000 / portTICK_RATE_MS );

Then I modified the code of TASK1 to take values of 12 ADCs. The code compiles but doesn't work. The code which I wrote is something like this:
 void vTask_ADC ( void *pvParameters )
for( ;; )
AD1CON1bits.ASAM = 1;
vTaskDelay( 1000 / portTICK_RATE_MS );

Do I need to write the wrapper class to handle ADC? I have just written the attribute in a C file in which I just set and reset flags.
Thanks in advance.

RE: ADC interfacing using RTOS on PIC24FJ

Posted by Dave on April 4, 2013
I doubt your issue is FreeRTOS related. Try creating a loop in main() to read the ADC before the scheduler is started. Once you have that working it should also work inside your RTOS task as long as it does not do something like leave interrupts disabled.

RE: ADC interfacing using RTOS on PIC24FJ

Posted by Richard Damon on April 4, 2013
I think your biggest issue is that you are going to need to wait for the conversion to be complete before you read it. Since you don't show what vAverage_ADC_Readings() is doing, it is hard to say what is wrong.

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists