SteveB put me on the right track. I reviewed Darrel's posts on the subject, then sent him a PM. He responded with a link to a new page on his web site:
http://darreltaylor.com/DT_INTS-14/TimerTemplate.html
It appears to answer my question!
SteveB put me on the right track. I reviewed Darrel's posts on the subject, then sent him a PM. He responded with a link to a new page on his web site:
http://darreltaylor.com/DT_INTS-14/TimerTemplate.html
It appears to answer my question!
Russ
N0EVC, xWB6ONT, xWN6ONT
"Easy to use" is easy to say.
Hi Russ,
From your first mail it seems you have already done your project using the 8051 core. Let me tell you my experience.
I know only Programming in BASIC. I work with both the PIC BASIC and the BASCOM 8051 compilers. PIC basic does not support nesting of interrupts. To say all interrupts will vector to only one address location and you can not find which interrupt had called the ISR. Unlike PIC BASIC, BASCOM can have multiple interrupts, and you can determine its priority. Say for example you are using int0 and timer0...
The code in BASCOM goes like this..
ON TIMER0 tim0 ' on timer0 interrupt go to ISR tim0
ON INT0 int_0 ' on external interrupt go to ISR int_0
PRIORITY SET INT0
This sort of feature is not there in PIC BASIC. Some call it software interrupt.
THe command is ON INTERRUPT. The PIC BASIC also has tremendous amount of interrupt latency, ie the time taken between when the interrupt had occured and when it actually enters the ISR.
BASCOM has a wonderful simulator, with which you can see all the SFR and the variables change. From the timer counter you can find out exactly how much time it take to enter into your ISR from the instant interrupt occured. All this can be viewed in the simulator.
Time critical projects certainly require a simulator. The external interrupts can also be software generated in the bascom simulator.
I certainly would love to have such a simulator in PBP. Which will verymuch reduce our development time. Without a simulator you are like blind man searching for a screw in a maze.
If you are serious about using interrupts and all the hardware features of the PIC i suggest you start learning assembly language. Thats the best way to go untill they come out with a more enhanced way of interrupt handling in basic.
I would like to have the comments of other participants in this thread.
Thanks
Raghunathan
Raghunathan,
They didn't, but I did.Thats the best way to go untill they come out with a more enhanced way of interrupt handling in basic.
You may want to take a look at my Instant Interrupts (DT_INTS).
http://www.darreltaylor.com/DT_INTS-14/intro.html
It solves all the problems you just mentioned.
For the simulator, you can do that with MPLAB.
Or debug the real thing with Microcode Studio Plus.
<br>
DT
Raghunathan,
Thanks for your comment. All of my work with the MCS-51 family has been in assembler, C, or Small C (Small C also with the 68HC11); I have no experience with BASCOM.
As I mentioned before, I was referred by SteveB to Darrel's work and inquired by PM (thanks, Darrel!). He has got this issue nailed. Check the web site!
http://www.darreltaylor.com/DT_INTS-14/intro.html
I also downloaded DT_INTS-14.bas and ReEnterPBP.bas, printed them out, and walked myself through how he does it. This is a worthwhile exercise.
See especially http://darreltaylor.com/DT_INTS-14/layers.html.
Last edited by RussMartin; - 4th September 2006 at 21:33.
Russ
N0EVC, xWB6ONT, xWN6ONT
"Easy to use" is easy to say.
Raghunathan,
Your explaination of using the PICs interrupts is not quite fair. The limitations you mention are mostly a function of PIC BASIC Pro, not the PIC. Darrel touched on it, but here's a little more.
You can actually "find which interrupt had called the ISR" quite easly by tesing the Interrupt Flag in the ISR for the interrupts you expect. Additionally, the 16-bit PICs (18Fxxxx) have high and low priority interupts (which are usable by PBP). These vector to different locations, and as would be expected, a High Priority event can interrupt a Low Priority Interrupt, but no the other way around.Originally Posted by ra68gi
Yes, this is quite true. And the reason for this is that PIC BASIC Pro will finish executing the BASIC command before going to the ISR. And since each PIC BASIC Pro commands are made up of many ASM commands, there could be quite a large delay (especially if you had something like PAUSE 5000). The advantage though is that you can write your ISR entirely in PIC BASIC Pro, and don't have to worry about what's going on under the hood. But, if you can't afford any delays in your interrupts, you need to work the interrupts in ASM. Or use Darrel's Instant Interrupts.Originally Posted by ra68gi
As Russ mentioned, he "....walked [himself] through how [Darrel Taylor] does it. This is a worthwhile exercise". If you take the time, it's a great way to learn how to handle PIC interrupts (as well as the other neat tricks Darrel uses).
Steve
Last edited by SteveB; - 5th September 2006 at 05:19.
Thanks Darrel,
I have down loaded all the files associated with instant interrupts. It will take me a few days to learn them and use it in my projects.
Hi SteveB,
Thanks for your reply.
"And since each PIC BASIC Pro commands are made up of many ASM commands, there could be quite a large delay (especially if you had something like PAUSE 5000). The advantage though is that you can write your ISR entirely in PIC BASIC Pro, and don't have to worry about what's going on under the hood. But, if you can't afford any delays in your interrupts, you need to work the interrupts in ASM. Or use Darrel's Instant Interrupts."
I know that PBP commands are non re-entrant, but that is not the case with Bascom. What happens in bascom is the waitms can be interrupted and the only draw back is that the duration of the wait gets extended.
You have a free demo version Bascom in which you can write upto 2k. You also have an extensive user manual, which will get you started immediately. Just have a try. To get started in timers, counters and interrupts in basic it is the easiest. Hmmm... can't say until i have worked with Darrel's instant interrupts.
I will be working on a 50 hz line-interactive UPS design using a micro controller. The heart of the program will be to generate two 50hz out of Phase pulses whose duty cycle depends on a feed back from the output voltage of the UPS. I intend to use two timers for it. Timer0 to generate a constant 10ms(not exactly 10ms but say 9.5ms or so providing a dead band of 1ms between two pulses) and timer1 to measure time until my A/d value of the feed back(from the output transformer) reaches a preset value(which translates to 230v output).
There are 2 transistor banks. You first switch on one bank and check the a/d value. If the a/d value reaches the preset value, stop timer1 and switch of that bank. Now switch on the other bank exactly for the the same timer1 value. Each of the bank will be switched on only for the timer1 duration.If the banks are switched on for unequal time value, then there will be what we call a flux imbalance in the transformer core we switch onto. This would lead to huge amount of current drawn onto one bank of transistors and resulting in their failure. During the dead band period i have to make other measurements like battery voltage, mains incoming voltage etc.and control a few relays, leds and buzzer for incoming mains voltage regulation and annunciations.
There is already a thread on powersupply/ inverter in this forum.
Since i was interested in this project, i just thought it right to tell you because this is a project whic will have to use many of the hardware featue of the PIC.
Let me figure out a way to write the code with Darel's instant interrupts.
Thanks Guys, for your response.
Raghunathan
Bookmarks