FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [April 2013 Threads] ADC interfacing using RTOS on PIC24FJPosted 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; vAverage_ADC_Readings(); 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 PIC24FJPosted 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 PIC24FJPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|