Advertisement
abdullahkahraman

How to configure the internal oscillator of a PIC16F616?

Apr 19th, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. #include <xc.h>
  2. __CONFIG(FOSC_INTOSCIO & WDTE_OFF & PWRTE_ON & MCLRE_OFF & CP_OFF & IOSCFS_8MHZ & BOREN_ON);
  3.  
  4. void interrupt myInterrupt(void)
  5. {
  6.     if (T0IE && T0IF)
  7.     {
  8.         RA4 = ~RA4;
  9.         TMR0 = 254;
  10.         T0IF = 0;
  11.     }
  12. }
  13.  
  14. void main()
  15. {
  16.     TRISA = 0;
  17.     ANSEL = 0;
  18.  
  19.     PSA = 1; // Prescaler Assignment bit : 1 = Prescaler is assigned to the WDT, 0 = Prescaler is assigned to the Timer0 module
  20.     T0CS = 0; // T0CS: TMR0 Clock Source Select bit : 0 = Internal instruction cycle clock (FOSC/4), 1 = Transition on T0CKI pin
  21.     T0IE = 1; //T0IE: Timer0 Overflow Interrupt Enable bit
  22.     GIE = 1; //GIE: Global Interrupt Enable bit
  23.  
  24.     while (1);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement