Advertisement
tmax

Untitled

Jun 5th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #define _XTAL_FREQ_ 4000000
  2.  
  3. #include <pic16f873.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. int main(int argc, char** argv) {
  8.  
  9. //Configuro PWM
  10. T2CONbits.TMR2ON = 0;
  11. PR2 = 24; //Periodo de 40 KHz
  12. CCP1CONbits.CCP1Y = 1;
  13. CCP1CONbits.CCP1X = 0;
  14. CCPR1L = 0b00000110;
  15.  
  16. TRISCbits.TRISC2 = 0;
  17.  
  18. //Configuro timer 2
  19. T2CONbits.T2CKPS = 0b00; //Pre 1:1
  20.  
  21. CCP1CONbits.CCP1M = 0b1111;
  22. T2CONbits.TMR2ON = 1;
  23.  
  24. while(1);
  25.  
  26. return (EXIT_SUCCESS);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement