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

PICKIT2 RS232 software error PIC18F4620

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



Joined: 14 Jun 2010
Posts: 3

View user's profile Send private message

PICKIT2 RS232 software error PIC18F4620
PostPosted: Wed Oct 17, 2012 6:05 pm     Reply with quote

Hello!

I'm don't speak english...sorry

CCS ver: CCS PCH C Compiler, Version 4.134

PIC software: (PIC18F4620)
Code:

#use delay(clock = 4000000, RESTART_WDT)
#use rs232(baud = 9600, parity = N, xmit = PIN_E1, rcv = PIN_E2, bits = 8, stream = PORT1, restart_wdt, errors)

int16 c;
printf("Send RS232\r\n");
printf("press key\r\n");
/*  MAIN LOOP  */
do { Restart_Wdt();

c = getc(); 
putc(c);
fputc('A', PORT1);
Lcd_Putc(c); // --> show undefined char not ASCII

Restart_Wdt(); Delay_ms(2000);
 } while(True);


PICKIT2 result:
???????ß????
and not ASCII character

Hardware ok,
Software connect success

Please help.

Thank you very much!
asmallri



Joined: 12 Aug 2004
Posts: 1636
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 17, 2012 6:23 pm     Reply with quote

There are multiple problems with this.

There are no config fuses defined

The #use rs232(...) specifies you are using E1 and E2 for the serial port however this is not where the serial hardware module is located therefore you are forcing the driver to perform as a software UART. In which case it sits in a tight loop waiting for characters to be received.

You have specified ERRORS in the #use RS232 however this works ONLY for the HW UART where its roll to to recover from overrun errors which would have disabled the HW UART. There is no such thing as an overrun error on the CCS software UART as there is no serialisation going on unless you are specifically using a SW UART function such as gets()

You have specified in the #use rs232 to reset the WDT timer however you then do it in the main loop as well.

In the main loop you reset the WDT but then immediately delay for 2000ms. This is likely to be larger than the amount of time the WDT will count down before the PIC is reset. It is difficult to tell because you did not declare the WDT divisor settings in the config bits.

Any characters typed during the 2000ms delay will be lost because the software UART is not attempting to read any input during this delay as the delay function is basically a large NOP loop. At the end of this 2000ms delay you are then doing a get C but this could be half way through the reception of a serial character.

Don't use the SW UART if you can use the HW UART.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
MsDw



Joined: 14 Jun 2010
Posts: 3

View user's profile Send private message

Thanks
PostPosted: Sun Oct 28, 2012 6:58 am     Reply with quote

Hello!

Thank you very much, help me!
R232 communication ok! :D
I'm testing now, but don't free time.
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