Re: MikroBasic to PBP Pro: Boost mode SMPS
I'll give this a go... even though there are definately better programmers around here than me
With microcontrollers there is very few instances where things can "go on in the background". Acutally NONE as far as the main processor is concerned, it can only do one thing at a time. Most all PIC's include onboard peripherals like PWM channels or USART serial links, timers and counters, etc. (see the datasheet for your PIC of choice and it will list all the different functions that each pin can be set up for) these peripherals can be set up to do something in the background, like the PWM channel, where you define a given pulse width and it will continue to output that pulse at a given duration and frequency while your program continues on.
Now, you could set up the pushbutton to be tied to an I/O pin that had "Interrupt On Change" capability, either rising edge or falling edge. Then when you pushed the button an INT would be generated and the Pic could jump to the INT handler(check out Darrell Taylors "instant interrupts" for the "best" way to impliment interrupts.
OR you could just include a check for when the button pin changed state within the while/wend loop.
Remember... "can only do one thing at a time" is a relative statement... ie. if you push a button and the contact is closed for 200 msec's then that gives the processor a LOT of time the do something else and still get around to seeing that you are pushing a button.
good luck!
Last edited by Heckler; - 10th October 2011 at 21:06.
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Bookmarks