CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with 18F45K22 RS232 Configuration

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cvargcal



Joined: 17 Feb 2015
Posts: 134

View user's profile Send private message

Problem with 18F45K22 RS232 Configuration
PostPosted: Sat May 07, 2016 12:35 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 07, 2016 12:40 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 07, 2016 12:53 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sat May 07, 2016 7:36 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun May 08, 2016 9:09 am     Reply with quote

Glad you got it working!
_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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