- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
So I am trying to recreate the code in this application note (I can't find the link to the actual project)
I have read through all the PWM datasheet and I think I have everything setup right.. I am reading the status register as it says but when I step through my code it just never leaves the interrupt.. it goes off to read the status register and then just loops infinitely in the ISR routine..
I have attached my code if someone could help me make sense of where I am going wrong..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Your active PWM will generate interrupts all the time because it is hardware. When single-stepping through your code you will always stop in the interrupt handler. At first sight I would think that your code is right.
I (personally) do not use the way you defined the interrupt handler. When switching to another PSoC switch or when deleting the generated files (which is allowed to do) you are going to loose the modifications you made in the file ISR_Compare.c
When declaring the Handler with CY_ISR_PROTO(YourHandler) and defining it with CY_ISR(YourHandler) in your main.c you can start it with ISR_Compare_StartEx(YourHandler) and have full control of the code. Have a look into the "System Reference Guide" to be found under Creator -> Help -> System Reference.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am going to look into your way of doing it, but please could you elaborate on what you mean about the pwm always generating interrupts as it is hardware? also the single stepping thing.. I thought I would see the code exit the isr and back to main, then back to isr...etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The moment you started the PWM it runs ang generates interrupt. When your program reaches a breakpoint the PWM does NOT stop, only the program halts. When single-stepping you will not leave the current instruction. proceed as follows:
Program has halted at BP1
Place BP2 to the next instruction after the BP1.
Remove the BP1
Run program, it stops at BP2
Remove BP2
Set BP1 at the old position again
Run Program.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahh I get what you mean, but now I have done this and set a second breakpoint outside of the flag checking loop and surely the program should reach that.. but it doesn't, it never gets past the yellow line..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
another twist..
I have downloaded and programmed the following tutorials example project
http://blog.hendriklipka.de/archives/2013/10/psoc_frequency_counter_2.html
and the exact same happens, the code gets stuck in the ISR and doesn't respond to any change in frequency,.. is it my board do you think? or a bug?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
First post's answer: Did you remember that I wrote to delete (or at least to disable) the BP at the current line (or did I forget that)?
Second post's answer: This behaveour has Nothing to do with your board / PSoC. It happens with EVERY PSoC. The cause is how breakpoints are handled, how a run-command is issued and when the interrupt-flag in the PSW is cleared.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahh right, It is working now, but only if I go back and delete and replace breakpoints every time.. is that the only way to do debugging in PSoC creator because that is annoying as hell!
Thanks for the help by the way, very useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the only way to debug an interrupt handler. Additionally you may disable interrupts temporarily: there is a button on the menu-header to enable or disable them.
Bob