Advertisement
Guest User

user.c

a guest
Mar 14th, 2013
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.68 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 = 0b01000000;    //all analog mode, AD speed again reduced by 2x, no AD timer scaling, reference voltage is Vdd, Vss
  25.  
  26.     ADCON0 = 0b00000000;    //channel 0 selected, FOSC/4 , AD off initially, go_done unset
  27.  
  28.     PEIE = 1;               //turn on periph ints
  29.  
  30.     ADIE = 1;               //set AD ints
  31.  
  32.     GIE = 1;                //set general ints
  33.  
  34.     INTE = 0;               //RB external interrupts off
  35.  
  36.     RBIE = 0;               //RB port change functionality off
  37.    
  38.     ADIF = 0;               //clear flag
  39.    
  40.     ADON = 1;               //turn on AD now
  41.  
  42.     TRISA = 0xFF;           //porta as inputs
  43.  
  44.     TRISB = 0x00;           //portb as outputs
  45.  
  46.     PORTB = 0xFF;           //port b set high
  47.  
  48.     PORTA = 0x00;           //drive port a low
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement