Example Code
'Program History
'Date Author Comments
'29.09.04 JS This program works with original dev board, programming
' 877 via bootloader NO WDT
'30.09.04 JS RB port change interrupt changed to RB0 pin change
' Only 1 sw and 1 led used with led loop indicator
'30.09.04 JS Remove excess code
'30.09.04 JS RB0/INT interrupt working, correct settings for INTCON reg'r
' disable PortB pullups, RB0/INT falling edge as well as
' enabling and clearing the RBO/INT interupt
'
'
Include "PROTON_20.INC"
' Define the pins that are connected to pushbuttons.
' The switch must be connected to PORTB, pin0
Symbol SW1 = PORTB.0
' Define the pins that are connected to LEDs
Symbol LED1 = PORTD.0
Symbol LED2 = PORTD.1
INTCON.4 = 1 ' Enable the RB0/INT interrupt
OPTION_REG = $BF ' Enable PORTB pull-ups (was 7F-0111 1111)
' OPTION_REG.7=1 - Disable PORTB pull-ups
' OPTION_REG.6=0 - RB0/INT falling edge
TRISB = %00001111 ' Set PORTB.0-3 (SWs) to input, 4-7 (LEDs)to output
Output PORTD ' Enable portD to drive leds
'Pull RB4 High
High PORTB.4
'Test leds
LED1 = 1
LED2 = 1
delayms 1000
' MAIN PROGRAM BEGINS HERE
main:
'Leds off
LED1 = 0
LED2 = 0
'Led loop indicator
LED2 = 1
delayms 1000
LED2 = 0
' Check SW1 pressed to toggle on LED
If SW1 = 1 Then LED1 = 1
delayms 5000
INTCON.1 = 0 ' Clear the RB0/INT interrupt
Nap 7 ' Go to sleep. When the watchdog is
' disabled, NAP won't wake up until
' an interrupt occurs.
Goto main ' Do it again upon waking
'Date Author Comments
'29.09.04 JS This program works with original dev board, programming
' 877 via bootloader NO WDT
'30.09.04 JS RB port change interrupt changed to RB0 pin change
' Only 1 sw and 1 led used with led loop indicator
'30.09.04 JS Remove excess code
'30.09.04 JS RB0/INT interrupt working, correct settings for INTCON reg'r
' disable PortB pullups, RB0/INT falling edge as well as
' enabling and clearing the RBO/INT interupt
'
'
Include "PROTON_20.INC"
' Define the pins that are connected to pushbuttons.
' The switch must be connected to PORTB, pin0
Symbol SW1 = PORTB.0
' Define the pins that are connected to LEDs
Symbol LED1 = PORTD.0
Symbol LED2 = PORTD.1
INTCON.4 = 1 ' Enable the RB0/INT interrupt
OPTION_REG = $BF ' Enable PORTB pull-ups (was 7F-0111 1111)
' OPTION_REG.7=1 - Disable PORTB pull-ups
' OPTION_REG.6=0 - RB0/INT falling edge
TRISB = %00001111 ' Set PORTB.0-3 (SWs) to input, 4-7 (LEDs)to output
Output PORTD ' Enable portD to drive leds
'Pull RB4 High
High PORTB.4
'Test leds
LED1 = 1
LED2 = 1
delayms 1000
' MAIN PROGRAM BEGINS HERE
main:
'Leds off
LED1 = 0
LED2 = 0
'Led loop indicator
LED2 = 1
delayms 1000
LED2 = 0
' Check SW1 pressed to toggle on LED
If SW1 = 1 Then LED1 = 1
delayms 5000
INTCON.1 = 0 ' Clear the RB0/INT interrupt
Nap 7 ' Go to sleep. When the watchdog is
' disabled, NAP won't wake up until
' an interrupt occurs.
Goto main ' Do it again upon waking


Menu
Recent Articles


Using PDS with SPI GLCD based on ST7565R Controller
Graphic LCDs based on the ST7565 are cheaper then GLCDs with other controllers. SPI requires only four pins. If the circuit