Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************/
- /*Files to Include */
- /******************************************************************************/
- #if defined(__XC)
- #include <xc.h> /* XC8 General Include File */
- #elif defined(HI_TECH_C)
- #include <htc.h> /* HiTech General Include File */
- #endif
- #include <stdint.h> /* For uint8_t definition */
- #include <stdbool.h> /* For true/false definition */
- #include "globals.h"
- #include "delay.h"
- /******************************************************************************/
- /* Interrupt Routines */
- /******************************************************************************/
- /* Baseline devices don't have interrupts. Note that some PIC16's
- * are baseline devices. Unfortunately the baseline detection macro is
- * _PIC12 */
- #ifndef _PIC12
- void interrupt isr(void)
- {
- //if it's the AD interrupt
- if(ADIF==1)
- {
- //delay for some number of NOPs
- do_delay((ADRESH << 8) + ADRESL);
- //reset AD int flag
- ADIF = 0;
- //
- GO_DONE = 0;
- }
- }
- #endif
- void do_delay(unsigned short int AVAL)
- {
- //iterate between 0 and 1023 times
- for(unsigned short int i=0; i<AVAL; i++)
- {
- asm("NOP");
- }
- //toggle portb (make square wave)
- if(RB0==0)
- {
- RB0=1; //ternary operator
- RB1=1;
- }
- else
- {
- RB0=0;
- RB1=0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement