I'm using the ChipKit Wi-Fire board where I use an external ADC to capture data and transmit it over the SPI channel based on the Timer2 interrupt. Getting the Timer2 interrupt and ADC capture to work independently is no problem, it's only when I combine them together that something halts in an odd way. Below is my code, and basically, for testing purposes, I sample 50 samples, after which the Timer2 is disabled and I print out the numbers on the serial monitor. In the interrupt routine I set an interrupt flag, which will be caught in the main loop.
This code doesn't work as intended, it seems to halt. The problem is the "if(interrupt_flag == 1)" part, which is only being called once, and then nothing more happens. Instead, if my routine in the main loop, in case of an interrupt, looks like this:
it works. Here I use GPIO 4 to give a square pulse train which I can monitor on an oscilloscope, and the serial monitor prints out all 0s, as expected. I've tested the Timer2 interrup as well as the external ADC reading through SPI separately, and they both work on their own. It just seems to fail when I combine them.
Question
c64 0
Hi,
I'm using the ChipKit Wi-Fire board where I use an external ADC to capture data and transmit it over the SPI channel based on the Timer2 interrupt. Getting the Timer2 interrupt and ADC capture to work independently is no problem, it's only when I combine them together that something halts in an odd way. Below is my code, and basically, for testing purposes, I sample 50 samples, after which the Timer2 is disabled and I print out the numbers on the serial monitor. In the interrupt routine I set an interrupt flag, which will be caught in the main loop.
This code doesn't work as intended, it seems to halt. The problem is the "if(interrupt_flag == 1)" part, which is only being called once, and then nothing more happens. Instead, if my routine in the main loop, in case of an interrupt, looks like this:
it works. Here I use GPIO 4 to give a square pulse train which I can monitor on an oscilloscope, and the serial monitor prints out all 0s, as expected. I've tested the Timer2 interrup as well as the external ADC reading through SPI separately, and they both work on their own. It just seems to fail when I combine them.
Any ideas?
Edited by JColvintags
Link to post
Share on other sites
3 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now