This program uses Timer0 and the PICs interrupt system to flash an LED connected to GP2 on the PIC 12F683.
The program uses a special kind of subroutine called an interrupt service routine (ISR), but there’s no ‘call’ instruction anywhere in the code. Instead, the subroutine is called by the PIC hardware by enabling interrupts.
To keep [...]
Continue reading about 12F683 Flashing LED using Timer0 and interrupts
While I was looking for a solution to the EMC issue, I thought about turning the regular 122Hz PWM frequency into something more like white noise. The idea was to spread the spectrum of the emmited radiation so that at any one frequency, the signal would be weaker.
It didn’t work. The intended effect was minimal, [...]
This program is a bit of a novelty, it uses the PIC’s watchdog timer to flash an LED. It’s probably the least sensible way to make an LED flash, but it illustrates some interesting features of the 12F683 microcontroller.
A few things to note. We intentionally don’t use the CLRWDT instruction, we want the WDT to timeout and reset [...]
Continue reading about 12F683 Flashing LED using watchdog timer
The PIC 12F683 has 3 timers, Timer0, Timer1 and Timer2.
Timer0 is an 8 bit timer with an 8 bit prescaler and is currently being used to drive the LED pattern generator. Each time Timer0 overflows, a register called ‘pattern’ is incremented and analysed to determine whether the LED should turn on or off. These patterns [...]
This is the regulator circuit that generates 5 volts for the PIC microcontroller. The 1N4001 diode decouples battery voltage Vbatt from the regulator circuit. The various capacitors provide smoothing and decoupling to provide the microcontroller with a clean stable power supply. A 100n capacitor is connected as close to the PIC supply pins as possible.
The [...]
Gotta watch these PICs, they’re out to get you! Think I’ll flash an LED on GP0. Let’s see…
bsf GPIO,0
call delay
bcf GPIO,0
call delay
Hmm, doesn’t work. That’s because GP0 hasn’t been defined as an output. OK…
bcf TRISIO,0
bsf GPIO,0
call delay
bcf GPIO,0
call delay
Hmm, still doesn’t work. That’s because TRISIO is a register in the high bank. We need to switch [...]
Another consequence of having the FET on the high side of the load is that we need a high voltage supply to drive the FET gate. In previous tests, it was found that the FET would turn on with as little as 4.5 volts on its gate (with respect to its source), but the datasheet [...]
Here’s the circuit for battery voltage measurement. The zener diode (1N959B) drops 8.2 volts off the battery voltage to bring it closer to the 5 volt range that the microcontroller A/D converter can measure. The potential divider provides a further reduction and defines the maximum measurable battery voltage. The 1n5 capacitor smoothes out ripples caused by PWM [...]
Continue reading about Measuring Battery Voltage (revisited)
Centre stage is the PIC12F683