Please note that 'ALL_DIGITAL = TRUE' is NOT A SUBSTITUTE FOR SETTING YOUR PIC UP !!
| Device = 16F684 ' Define the Pic processor Xtal = 4 ' Define the clock speed so timing works out in the program Config_Start ' Define the pic fuses configuration here ' This tells the pic how it is configured to start up ' See the Fuse Configurator Plugin Config_End TRISA = %11011011 ' Configure I/O on port A TRISB = %00011111 ' Configure I/O on port B TRISC = %00000000 ' Configure I/O on port C or however many ports there are ' All ports must be configured otherwise the default setting ' will apply and they may not be what you want them to be ' 0 = Output, and a 1 = Input. Define unused pins as Outputs CMCON = %00000111 ' disable comparators if the pic have them and they are not used ' They are ENABLED by default ' Define peripheral and other registers here. ' If you are not going to use it, don't define it OSCCON.6=1 ADCON0 = %00001101 ' Alias the pins you are going to use on the ports. ' Anywhere in the code where you refer to Pot1 the pic will now know it is PortA.0 Symbol Pot1 = PORTA.0 ' Pot 1 A/D Input Symbol Pot2 = PORTA.1 ' Pot 2 A/D Input Symbol NC01 = PORTA.2 ' Not Used Output 'Define other aliasses for bits in registers you intend to use Symbol GIE = INTCON.7 ' Global Int En Bit Symbol Go_Done = ADCON0.1 ' Define the variables you use in the program. ' These can be added as you develop a need for them during programming Dim Coun As Dword ' Dim Revs As Word Dim Temp As Byte ' temp genl use reg Dim A As Bit ' A = flag to check 'If interrupts are not used then omit the following - '************************************************* ********************* '* Set up interrupts '************************************************* ********************* On Interrupt GoTo Label Goto Start 'jump over the Interrupt subroutine to program start '************************************************* ************************** '* Interrupt Handler When an interrupt occurs the code will jump to here '************************************************* ************************** Label: ' This is a program label or marker ' Do NOT execute part of the program here ' The idea is only to see what interrupted you ' Set a flag ie A = 1 or BSF Temp.1 or BSF Temp.5 ' Then handle the required action elsewhere ie in the main loop. ' Interrupt code is here Resume Enable '************************************************* ********************* '* Set up Preprocessor '************************************************* ********************* ' The following code will be placed in the code whenever you use Flash $define Flash ' LED = 1 ' Delayms 200 ' LED = 0 ' Delayms 300 '************************************************* ******************** '* Main Program Starts Here '************************************************* ******************** Start: ' It is important to use labels so the code has references where to jump to LED = 1 Gosub Timer1 ' Call a subroutine Led = 0 ' Subroutine will return to this line goto Start1 ' Code jumps to label Start1 ' Fast Flash here Start1: Flash ' The pre-processor code is inseted here If A = 1 then LED = 1 : A = 0 ' Interrupt occurred, LED On, reset flag Goto Start ' Jump to label Start '************************************************* ******************** '* Sub Routines are Here - '************************************************* ******************** ' A Subroutine is code you use over and over by jumping to it and back from within the program ' Timer Delay Timer1: Delayms 2000 Return ' Return to the next line from where the subroutine was calledEnd ' End of program statement |


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