12 Replies Latest reply on Apr 30, 2015 4:18 PM by user_14586677

    Task Scheduling with ADC

    syth.ryan

      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

        • 1. Re: Task Scheduling with ADC
          user_1377889

          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

          • 2. Re: Task Scheduling with ADC
            user_14586677

            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.

            • 3. Re: Task Scheduling with ADC
              syth.ryan

              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?

              • 4. Re: Task Scheduling with ADC
                user_14586677

                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.

                • 5. Re: Task Scheduling with ADC
                  syth.ryan

                  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?
                   

                  • 6. Re: Task Scheduling with ADC
                    user_14586677

                    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.

                    • 7. Re: Task Scheduling with ADC
                      syth.ryan

                       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

                      • 8. Re: Task Scheduling with ADC
                        user_14586677

                        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.   
                        • 9. Re: Task Scheduling with ADC
                          user_14586677

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

                             

                           

                             

                          Regards, Dana.

                          • 10. Re: Task Scheduling with ADC
                            syth.ryan

                            Edit: Answering myself, I need to do more :D

                               

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

                               

                             

                               

                             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

                               

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

                            • 11. Re: Task Scheduling with ADC
                              syth.ryan

                               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

                              • 12. Re: Task Scheduling with ADC
                                user_14586677

                                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.