TODOPIC
Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: fighter en 24 de Enero de 2013, 16:12:08
-
buenas Estoy teniendo problemas con la Uart, estoy casi seguro que el problema puede estar por la frec del osc y par tal motivo no genera bien el baud rate.
No puede ver los caracteres q salen de uart con el hipertermnal y no tengo problema con el hardware. Estoy usando un xtal de 12Mhz
#include <18F26J50.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES HS //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOPROTECT //Code not protected from reading
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES PRIMARY //Primary clock is system clock when scs=00
#FUSES NOWPCFG
#FUSES WPEND
#FUSES WPDIS
#FUSES NOCPUDIV
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES PLLDIV3
#FUSES T1DIG,MSSPMSK7 //No PLL PreScaler
#FUSES DSWDT2147483648,DSWDT,DSBOR,DSWDTOSC_INT,WPFP0,WPFP1,WPFP2,WPFP3,WPFP4
#use delay(clock=12M,type=xtal)
#use rs232(UART2,baud=4800,parity=N,xmit=PIN_B1,rcv=PIN_B0,bits=8,stop=1,stream=gps)
#use rs232(UART1,baud=9600,parity=N,xmit=PIN_A1,rcv=PIN_A0,bits=8,stop=1,stream=gsm)
saludos
-
Estos micros con relojes de mucha frecuencia, no generan bien el baudrate, me ha pasado.
Prueba con valores como 115200 a ver que pasa, contra hiperterminal o el que trae CCS mismo.
Tambien prueba con los pines del puerto, a ver si alli anda.
Tal vez te falte poner force sw. :mrgreen:
-
Hola,
Esta configuración está funcionando correctamente con un cristal de 20Mhz, no es el mismo micro, pero tal vez te sirva
#include <18F24J50.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCPUDIV
#FUSES NOPROTECT //Code not protected from reading
#FUSES HSPLL //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES PLL5
#FUSES T1DIG
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES DSWDTOSC_INT
#FUSES RTCOSC_T1
#FUSES NODSBOR
#FUSES NODSWDT
#FUSES DSWDT2
#FUSES NOIOL1WAY //Allows multiple reconfigurations of peripheral pins
#FUSES MSSPMSK7
#FUSES NOWPFP
#FUSES WPBEG
#FUSES NOWPCFG
#FUSES WPDIS
#use delay(clock=48000000)
#pin_select U2RX=PIN_B7
#pin_select U2TX=PIN_B6
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=Puerto1)
#use rs232(baud=9600,parity=N,xmit=PIN_B6,rcv=PIN_B7,bits=8,stream=Puerto2,enable=PIN_C1)
Importante añadir en el main
setup_oscillator (OSC_PLL_ON); //IMPORTANTIIIISIMO SI NO NO FUNCIONA USB NI USART
Suerte!!!
-
ya lo solucione. ahora tengo el problema q no puedo hacer andar las interrupciones serie. estoy usando CCS
como se asocian las intetrupciones a cada puerta serie? #use rs232(uart1...... se asocia con la #int_RDA
#use rs232(uart2...... se asocia con la #int_RDA2
gracias
-
Hola fighter, soy Leonidas y tengo el mismo problema quisiera saber si ya lo resolviste y si nos puedes decir como lo hiciste gracias.
-
ya lo solucione. ahora tengo el problema q no puedo hacer andar las interrupciones serie. estoy usando CCS
como se asocian las intetrupciones a cada puerta serie? #use rs232(uart1...... se asocia con la #int_RDA
#use rs232(uart2...... se asocia con la #int_RDA2
gracias
Recuerdo haberlo utilizado como indicas.
#use rs232(UART1,baud=9600,stream=COM1)
#use rs232(UART2,baud=9600,stream=COM2)
Luego añadir las rutinas de las interrupciones.
#int_RDA
void RDA_isr(void)
{
.....................
}
#int_RDA2
void RDA2_isr(void)
{
.................
}
y activarlas
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
enable_interrupts(INTR_GLOBAL);