Created
June 6, 2015 05:52
-
-
Save vintagechips/b5883f965d340fbf2fe9 to your computer and use it in GitHub Desktop.
PIC12F1822 application for baud rate generator(9600bps * 16 = 153600Hz).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//baud rate generator | |
//device: PIC12F1822(5V) | |
//compiler: HI-TECH PICC 9.80a | |
#include <pic.h> | |
__CONFIG(FOSC_INTOSC & WDTE_OFF); | |
void main(){ | |
OSCCON = 0b11110000; //32MHz | |
OSCTUNE = 63; //tune | |
ANSELA = 0; //digital | |
TRISA = 0; //output | |
CCP1CON = 0b00001100; //PWM mode | |
PR2 = 51; //PWM cycle | |
CCPR1L = PR2 / 2; //duty cycle | |
CCPR1H = PR2 / 2; //initial duty cycle | |
T2CON = 0; //not use prescale | |
TMR2 = 0; //TMR2 clear | |
TMR2ON = 1; //TMR2 start | |
while(1){ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment