Toggling LED with Timer Interrupt

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

cross mob
Anonymous
Not applicable

  Hi all,

   

   I am a beginner with PSoC 1. Having gone through many app note, i tried my first ever project in PSoC. My aim was to toggle an LED every 1s. Maximum possible configuration ( Vc1 divider= 16, vc2 divider= 16, vc3 (sourced by Vc2) =256 and timer period = 256) gave me 0.6 s . Since it is perceptible i continued as such. In my power Psoc  board an LED is connected to P1_5 . I configured those pins (initial value as 1) . when i programmed the Psoc my led kept on glowing(remaining in its inital value assigned)  no toggling. I have checked for declaration of interrupts and all. I couldnt find more mistakes with my knowledge.

   

 

   

I have attached my project.

   

Kindly help

   

Thanks,

   

Sundar 

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

I cannot see your attachment yet. Build -> Clean project, then Zip (NOT RAW) the folder and upload it here.

   

Bob

0 Likes
Anonymous
Not applicable

sorry my connection is a bit slow...

   

I have attached it now

0 Likes
Anonymous
Not applicable

 I have problem with attaching my file :(..
Now i am trying again....

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

If you are using ISRs make sure you modify boot.tpl file in your root project

   

directory.

   

 

   

Some useful references on setting up ISRs -

   

 

   

If you added ISR driven code, a couple of rules of thumb -

   

1) Do not make f() calls from within ISR unless you cannot avoid it. That
is because compiler will do a ton of saves, like full stack, etc. to make sure
it can return fully and properly. That in  turn slows machine down considerably.
Look at your listing file to see what the compiler does with your ISR code.

   

2) Best practice is simple, set a flag inside ISR and return to main() to process ISR.

   

3) Set up ISR to "fire" as infrequently as possible. If you only need ISR at a low rate,
don't  "oversample" it, that would be just a waste of MIPS.

   

4) Look at coding. If you have multiple ISRs, is there any ISR that can essentially
negate the need to process another pending ISR, eg. compute not when not
needed. If you have an ISR that needs a lot of MIPs occasionally, you can always
skip another pending ISR if by doing so nothing terrible happens.

   

5) If list file shows compiler generating wacky stuff, consider ASM for the ISR
routine.

   

6) Turn off optimization when first debugging ISRs, then look at it again after
optimization turned back on, to make sure compiler did not "optimize" in some
crazy jump or other unnecessary code.

   

7) If display issues are affected, jitter, etc.., consider creating a display buffer in
RAM. And when a write is needed first check if RAM already displaying what you
want, if so do nothing, or update RAM and write to display if needed. This some-
times can cure ISR driven display  update issues.

   

http://www.cypress.com/?id=4&rID=36720

   

http://www.planetpsoc.com/component/content/article/43-writing-a-c-isr.html

   

http://www.planetpsoc.com/psoc1-articles-digital/13-basics-of-psoc-gpio.html?start=7

   

 

   

Regards, Dana.

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

I just solved a similar project here http://www.psocdeveloper.com/forums/viewtopic.php?f=3&t=8695 , maybe this can help you.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Don't use Google Chrome to attach files. Try a different browser.

0 Likes