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
The purpose of the charge controller is to fill the battery with charge as quickly as possible without causing any damage.
Letting the battery voltage rise to 13.5 volts, then holding it there using PWM is fine, but the battery saturates (fills with charge) slowly. Allowing the voltage to rise initially to 14.4 volts, then dropping [...]
Continue reading about Saturation Charge and External Influences
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 [...]
So far, not much has been said about the process of writing software for the PWM solar charge controller, so let’s rectify that.
Prototype code has already been written; a friend and I developed the current software during three 1-day programming sessions. The basic feedback control mechanism, which holds the battery voltage at a selected target [...]
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 [...]
This program flashes LED D6 on the PICkit1 programmer board using the PWM hardware. The microcontroller’s clock is set to 125kHz to make the pulse frequency low enough to see the LED turning on and off.
;12F683 Flashing LED using PWM
list p=12F683
#include “p12f683.inc”
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF
org 0×00
init
clrf GPIO ;initialise all outputs
movlw 0×0c
movwf CCP1CON ;select PWM mode (active high)
movlw 0×80
movwf CCPR1L ;set PWM duty cycle to [...]
This program flashes LED D0 on the PICkit1 programmer board using software delays. Two general purpose registers, del_lo and del_hi form a 16 bit counter (65,536 counts). The delay subroutine is called between each change of state of the LED.
;12F683 Flashing LED using software delay
list p=12F683
#include “p12f683.inc”
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF
del_lo equ 0×20
del_hi equ 0×21
org 0×00
init
clrf GPIO ;initialise all outputs
banksel 0×80 ;select upper register bank
movlw 0×0f
movwf TRISIO ;make [...]
Continue reading about 12F683 Flashing LED using software delays