Friday, March 1, 2013
uso del usart con oscilador interno C18
#include
#include
#include
#include
//Fuses para trabajar con 8Mhz/////////
#pragma config FOSC = INTOSCIO_EC //Usamos UN CRISTAL DE 20MHZ JUNTO CON UN PLL
#pragma config PLLDIV = 5 //PLL DIV 20Mhz/5=4Mhz
#pragma config CPUDIV = OSC1_PLL2 //CPUDIV1 96Mhz/2=48Mhz
#pragma config USBDIV = 2 //tRABAJAMOS CON USB CLOCK divido en dos
#pragma config VREGEN = OFF //Trabajamos sin regulador interno 3.3v para usb
#pragma config FCMEN = ON,IESO = ON
#pragma config PWRT = ON, BOR = OFF,BORV = 0
#pragma config WDT = OFF,WDTPS = 32768
#pragma config MCLRE = ON,LPT1OSC = OFF,PBADEN = OFF,CCP2MX = OFF
#pragma config STVREN = OFF,LVP = OFF,XINST = OFF,DEBUG = OFF
#pragma config CP0 = OFF,CP1 = OFF,CP2 = OFF
#pragma config CPB = ON,CPD = ON
#pragma config WRT0 = OFF,WRT1 = OFF,WRT2 = OFF
#pragma config WRTB = OFF,WRTC = OFF,WRTD = OFF
#pragma config EBTR0 = OFF,EBTR1 = OFF,EBTR2 = OFF
#pragma config EBTRB = OFF
void config(void){
TRISC&=0x80;
OpenUSART( USART_TX_INT_OFF & //Disable Interrupts
USART_RX_INT_OFF & //----------------
USART_ASYNCH_MODE & //Modo asincronico
USART_EIGHT_BIT & //8 bit
USART_CONT_RX & //resepcion continua
USART_BRGH_HIGH,
25); //FOSC / (16 * (spbrg + 1))
//spbrg=((FOSC/BAUD)/16)-1
//25=((8Mhz/19200)/16)-1
}
void main(void){
OSCCON=0x70;
config();
printf("HOLA PIC18\r\nCorriendo a 8Mhz\r\n");
while(1){
printf("Velocidad a 8Mhz/4\r\n");
Delay10KTCYx(255);
}
}
Currently have 0 comentarios: