|
|
View previous topic :: View next topic |
Author |
Message |
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
Problem with 18F45K22 RS232 Configuration |
Posted: Sat May 07, 2016 12:35 pm |
|
|
Hi, i have problem with this pic... Not work the RS232 by Hardware.
The port by Software if work :/
Someone know what configuration should I do.?
Code: | #include <18LF45K22.h>
#device ADC=10
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR //Master Clear pin disabled
#use delay(crystal=12MHz)
#use STANDARD_IO( A,B,C,D,E )
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_C0,rcv=PIN_C1,ERRORS,stream=debug) // Configuración debug (Software)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_C6,rcv=PIN_C7,ERRORS,stream=uart1) // Configuración UART1 (Hardware)
#use rs232(baud=9600,bits=8,parity=N,xmit=PIN_D6,rcv=PIN_D7,ERRORS,stream=uart2) // Configuración UART2 (Hardware)
#define LED PIN_C2
#define DELAY 1000
void main(){
setup_timer_0(T0_OFF);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8); // 174 ms overflow, Setup timer: Reloj interno, preescaler= 8
set_timer1 (0xE4D); // Carga del TMR1 0.165=4/12000000*8(65536-x),x=3661 >> Tiempo de desbordamiento es 0.165 segundos
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_timer_4(T4_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
setup_ccp3(CCP_OFF);
setup_ccp4(CCP_OFF);
setup_ccp5(CCP_OFF);
setup_dac(DAC_OFF);
setup_adc(ADC_OFF | NO_ANALOGS);
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_wdt(WDT_OFF);
fprintf(uart1,"Hola mundo");
fprintf(uart2,"Hola mundo");
fprintf(debug,"Hola mundo");
while(TRUE)
{
//Example blinking LED program
output_low(LED);
delay_ms(DELAY);
output_high(LED);
delay_ms(DELAY);
//TODO: User Code
}
} |
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sat May 07, 2016 12:40 pm |
|
|
First thing I see is that you are using reserved words for the stream names.
Try using something besides UART1 and UART2 like U1 and U2
Try this: (default is 9600/N/8/1)
#use rs232(UART1,ERRORS,stream=U1) // Configuración UART1 (Hardware)
#use rs232(UART2,ERRORS,stream=U2) // Configuración UART2 (Hardware) _________________ Google and Forum Search are some of your best tools!!!! |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Sat May 07, 2016 12:53 pm |
|
|
dyeatman wrote: | First thing I see is that you are using reserved words for the stream names.
Try using something besides UART1 and UART2 like U1 and U2
Try this: (default is 9600/N/8/1)
#use rs232(UART1,ERRORS,stream=U1) // Configuración UART1 (Hardware)
#use rs232(UART2,ERRORS,stream=U2) // Configuración UART2 (Hardware) |
I alway use this configuration for others pic, and i have not problem...
i changed this, but still not work... I think the problem is C6,C7 and D6,D7 this pins need some configurations. :/
Thanks you. |
|
|
cvargcal
Joined: 17 Feb 2015 Posts: 134
|
|
Posted: Sat May 07, 2016 7:36 pm |
|
|
dyeatman wrote: | First thing I see is that you are ............
Thanks you. |
Excuse me, the code work... the problem was mine. :/ |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Sun May 08, 2016 9:09 am |
|
|
Glad you got it working! _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|