View Single Post
Old 10-08-2015, 10:00 PM   #2156 (permalink)
e*clipse
Permanent Apprentice
 
Join Date: Jul 2010
Location: norcal oosae
Posts: 523
Thanks: 351
Thanked 297 Times in 213 Posts
Quote:
Originally Posted by MPaulHolmes View Post
The dspic has priority levels for the interrupts. 0-7. If priority(A) < priority(B), B can interrupt A, but A cannot interrupt B. I have it set so that the only thing higher than the A/D is the change notification interrupt, which is catastrophically bad if that happens(well, hardware overcurrent, which isn't so bad. haha), and you have to cycle power because the hardware has permanently disabled everything until then. So I don't think anything bad can happen. I just like to have all the stuff happen in the A/D interrupt so that I know which currents/voltages go with the FOC calculations. It could happen that outside the interrupt you use phase A current from 0.0001 seconds before, and phase B current from now, which defeats the simultaneous A/D sampling. I'm sure there's a way around it, like seeing when counter10k has incremented, but then you are having to check other stuff rather than just doing what needs to be done. My thinking was, as long as nothing bad can happen, it's OK if 99% of the time is in the A/D interrupt. The UART interrupts just have to get to the back of the bus. haha. The UART interrupts are pretty much Rosa Parks. I very much like your organizational ideas, btw. I need to be able to tear things down and try a bunch of stuff with a working copy though. Although quite a bit of stuff isn't changing, so I think it will be pretty practical for you to work on what you are talking about, and I use a copy based on something that has been reorganized.
Let me just start by saying this is why I LOVE working with you! It's about getting the best result - and it's fun.

I'll try to figure out a solution for the AtoD interrupt thing. I think you have a very good point. I'll try to figure out a solution - If it's not 100%, I won't even ask.

For now, I've got things swapped around; I've split up InitAD into three separate (but right next to each other functions. I've put the fault checking in a separate function too.

I haven't done anything with the ADC interrupt except move it.

I'll double check that there aren't any stupid compiler errors, then
****edit*****
Ok, it builds! Yea! I'll just clean up some of my editing stuff....
***********

Then I'll e-mail you what I've got. If it makes sense, great - otherwise throw it back at me!

Last edited by e*clipse; 10-08-2015 at 10:14 PM..
  Reply With Quote
The Following User Says Thank You to e*clipse For This Useful Post:
MPaulHolmes (10-08-2015)