Guest User

main.c

a guest
Mar 14th, 2013
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.56 KB | None | 0 0
  1. /******************************************************************************/
  2. /* Files to Include                                                           */
  3. /******************************************************************************/
  4.  
  5. #if defined(__XC)
  6.     #include <xc.h>         /* XC8 General Include File */
  7. #elif defined(HI_TECH_C)
  8.     #include <htc.h>        //HiTech General Include File
  9. #endif
  10.  
  11. #include <stdint.h>         //For uint8_t definition
  12. #include <stdbool.h>        //For true/false definition
  13.  
  14. #include "system.h"         //System funct/params, like osc/peripheral config
  15. #include "user.h"           //User funct/params, such as InitApp
  16.  
  17. /******************************************************************************/
  18. /* User Global Variable Declaration                                           */
  19. /******************************************************************************/
  20.  
  21. /******************************************************************************/
  22. /* Main Program                                                               */
  23. /******************************************************************************/
  24. void main(void)
  25. {
  26.     /* Configure the oscillator for the device */
  27.     ConfigureOscillator();
  28.  
  29.     /* Initialize I/O and Peripherals for application */
  30.     InitApp();
  31.  
  32.     //may not be necessary
  33.     OPTION_REG = 0b00000000;    
  34.  
  35.     //main loop
  36.     for(;;)
  37.     {
  38.         //wait for return from ADC int
  39.         while(GO_DONE==1);
  40.        
  41.         //40 NOPs = 20 us @ 2 MIPs (19.72 us required at room temperature 77F/25C)
  42.        
  43.         asm("NOP"); //0
  44.         asm("NOP");
  45.         asm("NOP");
  46.         asm("NOP");
  47.         asm("NOP");
  48.         asm("NOP");
  49.         asm("NOP");
  50.         asm("NOP");
  51.         asm("NOP");
  52.         asm("NOP"); //10
  53.        
  54.         asm("NOP"); //11
  55.         asm("NOP");
  56.         asm("NOP");
  57.         asm("NOP");
  58.         asm("NOP");
  59.         asm("NOP");
  60.         asm("NOP");
  61.         asm("NOP");
  62.         asm("NOP");
  63.         asm("NOP"); //20
  64.        
  65.         asm("NOP"); //21
  66.         asm("NOP");
  67.         asm("NOP");
  68.         asm("NOP");
  69.         asm("NOP");
  70.         asm("NOP");
  71.         asm("NOP");
  72.         asm("NOP");
  73.         asm("NOP");
  74.         asm("NOP"); //30
  75.        
  76.         asm("NOP"); //31
  77.         asm("NOP");
  78.         asm("NOP");
  79.         asm("NOP");
  80.         asm("NOP");
  81.         asm("NOP");
  82.         asm("NOP");
  83.         asm("NOP");
  84.         asm("NOP");
  85.         asm("NOP"); //40
  86.  
  87.         //AN0 pin has had time to acquire voltage
  88.         GO_DONE = 1;
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment