;********************************************************** ;* blink.asm ;* Small demo program ;* for the SALT 16F876 board. Blinks light attached to c0. ;********************************************************** ;* Uses an inner and an outer loop structure to achieve ;* a delay long enough to see the blink on LED indicators. ;* ;* Walt Bankes, 2002 ;********************************************************** ;********************************************************** ;* BOARD DESCRIPTION - SALT 16F876 board ;* including some instructions ;* usually necessary for the operation of this board. ;* ;* Some connections to this board may seem strange to ;* an experienced board designer. Most of these ;* strange "features" are manifestations of trade offs ;* required to place all of the traces on one side of ;* the printed circuit board without resorting to ;* jumper wires. ;* It appears 18FXXXX PICs will be available sometime ;* soon that are pin compatable with the 16F876. They ;* will probably allow this board to be used more ;* readily with higher level languages since the ;* 18 series parts have an architecture and more ;* memory specifically to accomodate that. ;********************************************************** ;* Power supply options: ;* +5v. DC is required to power the micro controller. ;* ;* 5 volts may be supplied externally through board pins ;* 1 and 2. If you choose that option four parts may ;* be left off of the board - the power connector, the ;* bridge recifier, the 5 v regulator, and the 470 uf cap. ;* ;* By installing the power supply parts mentioned above ;* you may connect a wide variety of "wall wart" supplies ;* to the board. In which case you will have +5 volts ;* available on board pins 1 and 2 to power experiments. ;* The range of power supplies acceptable are from ;* 6 to 12 volts AC or 9 to 18 volts DC of either polarity. ;* ;* Edge Connector Pin assignments:(Viewed left to right ;* from the switch edge of the top of the board). ;* ;* 1 GND ;* 2 +5v ;* 3 GND ;* 4 SPARE PIN ;* 5 SPARE PIN ;* 6 PORT RC7 I/O ;* 7 PORT RC6 I/O ;* 8 PORT RC5 I/O ;* 9 PORT RC4 I/O ;* 10 PORT RC3 I/O ;* 11 PORT RC2 I/O ;* 12 PORT RC1 I/O ;* 13 PORT RC0 I/O ;* 14 SPARE PIN ;* 15 SPARE PIN ;* 16 GND ;* 17 PORT RA1(I/O) or AN1(analog input) ;* 18 PORT RA0(I/O) or AN0(analog input) ;* ;* Switch assignments:(Viewed left to right from the ;* switch edge of the top of the board ). ;* Off(up) = logic 1, On(down) = logic 0 ;* ;* 8 PORT RB0 ;* 7 PORT RB1 ;* 6 SPARE SWITCH ;* 5 SPARE SWITCH ;* 4 PORT RB2 ;* 3 PORT RB3 ;* 2 PORT RB4 ;* 1 PORT RB5 ;* ;* Oscillator frequency is about 1.4 MHz using the RC ;* option with R = 4.7 Kohms and C = 100 pf. ;* For R = 10 Kohms the osc. freq is 0.8MHz. ;* That freq. is useful for using PWM for servo motors. ;* The board includes the pads to, instead, use ;* ceramic resonators with intergal capacitors. 4 MHz ;* and 20 MHz have been successfully tested. ;********************************************************** list p=16f876 ; Include file, change directory if needed include "p16f876.inc" ; Start at the reset vector org 0x000 nop ;Required by ICD module Start banksel PORTC ;PORTC is connected to edge connector movlw B'01000001' ;Fosc/8, ch#0, A/D enabled movwf ADCON0 ;only ch#0 & #1 are connected to the board edge banksel OPTION_REG movlw B'00000111' ;Enable port B pullups needed because the switches ;driving portB are single throw, movwf OPTION_REG ;TMR0 prescaler, 1:256 clrf TRISC ;Define PORTC all outputs ;AN2&3 are wired directly to power and ground. Therefore, those pins ;MUST be defined as Vref+ and Vref-. For this board that means bits ;3..0 of ADCON1 must have the bit pattern of 1111 or 1101. movlw B'00001111' ;Left justify,1 analog channel movwf ADCON1 ;VDD and VSS references banksel PORTC ;* End of SALT 16f876 board description - including some instructions ;* usually necessary for the operation of that board. ;********************************************************************************** ;* This program is written to be assembled using MicroChip MPLAB IDE ;* and downloaden into the SALT 16F876 board using the Microchip ;* In Circuit Debugger module (ICD). ;* It may, also, be debugged using the MPLAB Simulator. ;* Three assembly warnings "Register in operand not in bank 0" are normal. ;********************************************************************************** ;* Beginning of BLINK program. ;* Inner loop delay counter - w reg - address 200. ;* Outer loop delay counter - address 20. ;*Main ;*Turn on light ;* Do outer loop ;* Do inner loop ;* Until inner loop done ;* Until outer loop done ;*Turn off light ;* Do outer loop ;* Do inner loop ;* Until inner loop done ;* Until outer loop done ;*Go to main ;*********************************************************************************** Main bsf PORTC,0 ;turn on output, portc - bit 0. ;**Delay loop 1. loop1 addlw 0x01 ;Increment inner counter. btfss STATUS,2 ;Loop until inner counter = 0. goto loop1 incfsz 0x20,f ;Loop until outer counter = 0. goto loop1 bcf PORTC,0 ;turn off output, portc - bit 0. ;**Delay loop 2. loop2 addlw 0x01 ;Increment inner counter. btfss STATUS,2 ;Loop until inner counter = 0. goto loop2 incfsz 0x20,f ;Loop until outer counter = 0. goto loop2 goto Main ;Do it again. end