Task Scheduling with ADC

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

   

I can't find examples of this in C or with the Built in modules. How would I make a task scheduler so that I can read my ADC switch Channels and read again.. and so on. 

   

Thanks, Examples are usually the best

0 Likes
1 Solution
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Normally when one talks of a task scheduler you think of an RTOS -

   

 

   

    

   

          

   

 

   

http://www.cypress.com/?rID=2809    AN2046 - PSoC® 1 Simple RTOS (Task Scheduler)

   

 

   

 

   

Regards, Dana.

View solution in original post

0 Likes
12 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A task-scheduler in a PSoC1 is a rather tight program eating up a lot of resources (flash, sram). In the embedded world you usually have a main loop that is executed as long as power is applied. Within this loop you can read your ADC, switch to the next channel, output the data, read ADC......

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Normally when one talks of a task scheduler you think of an RTOS -

   

 

   

    

   

          

   

 

   

http://www.cypress.com/?rID=2809    AN2046 - PSoC® 1 Simple RTOS (Task Scheduler)

   

 

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

RTOS_Timer8.h doesn't seem to be available for my model.  Would I be able to do the same for a Timer8? if not am I able to "import" it?

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Thats just the naming of the Timer8. In its properties window

   

when you have selected it, you can change its name to anything.

   

 

   

Regards, Dana.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

That was exactly what I was looking for. However after setting everything up It seems that the program does not crash but my tasks are never called. Something to do with not satisfying the if statements? I've attached my project if anyone is up to help

   

 

   

Thanks Again

   

 

   

Edit: Could it have to do with not having parameters set up on my timer?
 

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

You have to clear up these warnings/errors for starters -

   

 

   

!W C:\Users\Dana\Desktop\xxRTOS\BICS\BICS\led_commands.c(37):[warning] missing return value
!W C:\Users\Dana\Desktop\xxRTOS\BICS\BICS\main.c(6): extra token ";" in preprocessor directive

   

 

   

And the timer properties window warnings -

   

 

   

  Level 5 Warning - Configuration bics, User Module Timer8: Capture value has not been initialized.
  Level 5 Warning - Configuration bics, User Module Timer8: TerminalCountOut value has not been initialized.
  Level 5 Warning - Configuration bics, User Module Timer8: CompareOut value has not been initialized.
  Level 5 Warning - Configuration bics, User Module Timer8: CompareType value has not been initialized.
  Level 5 Warning - Configuration bics, User Module Timer8: InterruptType value has not been initialized.
  Level 5 Warning - Configuration bics, User Module Timer8: ClockSync value has not been initialized.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

 Any suggestions on values? for the timer?

   

Edit: I will folow some suggested values on the document you gave me. Thanks For all The Help

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

And you have to modify boot.tpl interrupt vector (in root project directory) -

   

 

   

    

   

          

   

http://www.cypress.com/?id=4&rID=36720     PSOC 1 boot.tpl

   

http://www.cypress.com/?rID=91487     AN90833 - PSoC® 1 Interrupts

   

 

   

 

Regards, Dana.   
0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Use the same values as the begining of main() uses to setup timer.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Edit: Answering myself, I need to do more 😄

   

-------------------------------------------------------------------------

   

 

   

 is That what I Did in Timer8_INT.asm or is it different.

   

 

   

 

   

 

   

 

   

_Timer8_ISR:

   

 

   

   ;@PSoC_UserCode_BODY@ (Do not change this line.)

   

   ;---------------------------------------------------

   

   ; Insert your custom assembly code below this banner

   

   ;---------------------------------------------------

   

   ;   NOTE: interrupt service routines must preserve

   

   ;   the values of the A and X CPU registers.

   

   Push X ; save the A and X registers

   

   push A

   

   mov A,[__r0] ; save virtual registers

   

   push A

   

   mov A,[__r1]

   

   push A

   

   call _Process_Time_Slot_Counter ; C call Function

   

 

   

   pop A ;restore virtual registers

   

   mov [__r1],A

   

   pop A

   

   mov [__r0],A

   

   pop A ; restore A and X registers

   

   pop X

   

   ;---------------------------------------------------

   

   ; Insert your custom assembly code above this banner

   

   ;---------------------------------------------------

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

 I added an ljump and also put 

   

#pragma interrupt_handler Process_Time_Slot_Counter

   

is Process_Time_Slot_Counter not my interrupt_handler?

   

I had also uncommented

   

   PRESERVE_CPU_CONTEXT

   

   lcall _Process_Time_Slot_Counter

   

   RESTORE_CPU_CONTEXT

   

 

   

was _Process_Time_Slot_Counter not correct for the "lcall"?

   

 

   

I attached my project to be easier to see where I'm at

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The earlier links on setting up interrupt give you a simple

   

method of creating a C ISR routine, I highly recommend

   

that as opposed to doing it in ASM.

   

 

   

So you would have your own name for the ISR. Note in the

   

Imagecraft user manual in Designer documentation it shows also

   

how to declare a C interrupt.

   

 

   

Regards, Dana.

0 Likes