Advertisement
Guest User

user.c

a guest
Mar 11th, 2013
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 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 "user.h"
  15.  
  16. /******************************************************************************/
  17. /* User Functions                                                             */
  18. /******************************************************************************/
  19.  
  20. /* <Initialize variables in user.h and insert code for user algorithms.> */
  21.  
  22. void InitApp(void)
  23. {
  24.     ADCON1 = 0b00000000;    //all analog mode, no AD timer scaling, reference voltage is Vdd, Vss
  25.  
  26.     ADCON0 = 0b00000000;    //channel 0 selected, AD off initially, godone unset
  27.  
  28.     TMR1ON = 0;             //turn off TIMER1
  29.  
  30.     TMR2ON = 0;             //turn off TIMER2
  31.  
  32.     INTCON = 0b00000000;    //turn off all interupts
  33.  
  34.     CCP1CON = 0x00;         //turn off CCP
  35.  
  36.     SSPCON = 0x00;          //turn off SSP
  37.  
  38.     PEIE = 1;               //turn off periph ints
  39.  
  40.     ADIE = 1;               //set AD ints
  41.  
  42.     GIE = 1;                //set general ints
  43.    
  44.     ADON = 1;               //turn on AD now
  45.  
  46.     RB0 = 1;                //turn just the one B port on
  47.  
  48.     ADIF = 0;               //clear flag
  49.  
  50.     TRISA = 0xFF;           //porta as inputs
  51.  
  52.     TRISB = 0x00;           //portb as outputs
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement