PIC program #2: Binary Counter – FREE Preview!

play-sharp-fill

We now build and program a binary counter to learn some new instructions such as Increment and Bit Test.

This is the code for the program:

list p=16F1455 ; list directive to define processor
#include “p16F1455.inc” ; processor specific variable definitions

__CONFIG _CONFIG1, _FOSC_ECL & _WDTE_OFF & _PWRTE_OFF & _MCLRE_ON & _CP_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_ON & _FCMEN_OFF
__CONFIG _CONFIG2, _WRT_OFF & _CPUDIV_CLKDIV6 & _USBLSCLK_48MHz & _PLLMULT_3x & _PLLEN_ENABLED & _STVREN_ON & _BORV_LO & _LPBOR_OFF & _LVP_ON

errorlevel -302 , -207 ; suppress message 302 from list file

banksel TRISC
clrf TRISC
banksel LATC
clrf LATC
loopy1:
incf LATC
btfsc LATC, 4
clrf LATC
goto loopy1
end

 

Questions