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 support@ccsinfo.com

Soft RS-232 baud rate 115200 not being generated correctly??

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



Joined: 24 May 2005
Posts: 8
Location: New Jersey

View user's profile Send private message Visit poster's website

Soft RS-232 baud rate 115200 not being generated correctly??
PostPosted: Thu Feb 16, 2006 4:28 pm     Reply with quote

I am using a PIC16F876 with 20mhz oscillator. For several years I've used PCW v3.045 and the following code has worked w/o problems:
#include <16f876.h>
#fuses HS,NOWDT,NOPUT,NOBROWNOUT, NOLVP, NODEBUG
#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use delay (clock=20000000) //20mhz

// PortB OUT
#bit TXD = 6.4
// PortB IN
#bit RXD = 6.5
#use rs232(baud=115200, xmit=PIN_B4,rcv=PIN_B5)
void main() {
setup_adc_ports(NO_ANALOGS);
set_tris_a(0); //all out
set_tris_b(0xE1); // 1110 0001
set_tris_c(0xFB); // 1111 1011

printf("Initilization was successful!\r\n");
while (true)
printf("test\r\n");
}

We recently upgraded to PCWH v3.224 and the above code does not work correctly...specifically, nothing is getting printed out to the hyperterminal screen. If I lower the baud rate to 9600 and recompile, it works like I'd expect. As mentioned above, the same code with baud=115200 compiled on v3.045 works. I'm using a MAX3380E leveler/inverter chip. I've tried upgrading to v3.225, but same problem.

Any ideas? I suspect that the baud clock is not being generated correctly with this new compiler version.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 16, 2006 4:42 pm     Reply with quote

Quote:
We recently upgraded to PCWH v3.224

My records show that PCM vs. 3.224 came out on approximately
April 26, 2005. Vs. 3.225 came out on about May 27, 2005.
russr



Joined: 24 May 2005
Posts: 8
Location: New Jersey

View user's profile Send private message Visit poster's website

PostPosted: Thu Feb 16, 2006 4:48 pm     Reply with quote

PCM programmer wrote:
Quote:
We recently upgraded to PCWH v3.224

My records show that PCM vs. 3.224 came out on approximately
April 26, 2005. Vs. 3.225 came out on about May 27, 2005.

You r correct, we purchased it back in May, but didn't get around to actually testing out this feature until recently. Anyway, I'm not really sure what this has to do with the problem I posted.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 16, 2006 5:30 pm     Reply with quote

I just wanted everything to be accurate.

Anyway, I tested vs. 3.224, and the baud rate is incorrect. I was able
to make it work by changing the "baud" parameter in the #use rs232
statement to 109000. With a 20 MHz crystal, this generates a baud
rate of 115482 for a soft UART. This is only about 1% off, so it works
OK. I tested both transmit and receive with Hyperterminal.
Example:

Quote:
#include <16F877.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=20000000)

#use rs232(baud=109000, xmit=PIN_C6, rcv=PIN_C7, FORCE_SW)

void main()
{
char c;
printf("Start\n\r");

while(1)
{
putc(0x55); // Used to measure Tx baud rate

// c = getc();
// printf("%c", c);
}
}
russr



Joined: 24 May 2005
Posts: 8
Location: New Jersey

View user's profile Send private message Visit poster's website

PostPosted: Fri Feb 17, 2006 8:20 am     Reply with quote

Thanks PCMProgrammer!

So how come this is not listed as a feature that was corrected in later versions on the changes page here: http://www.ccsinfo.com/versions.shtml ?

Do you know what version this was corrected in, if any at all?
Ttelmah
Guest







PostPosted: Fri Feb 17, 2006 10:12 am     Reply with quote

russr wrote:
Thanks PCMProgrammer!

So how come this is not listed as a feature that was corrected in later versions on the changes page here: http://www.ccsinfo.com/versions.shtml ?

Do you know what version this was corrected in, if any at all?


Unfortunately, the list is about as comprehensive, as a three page telephone directory of the US...
For any single entry on the list, there are typically probably half a dozen other changes, and some (usually ones that perhaps only affect one processor, and were only themselves 'introduced' a version or two ago), never get mentioned.
There were posts here some time ago, about incorrect soft serial baud rates, and these then stopped, so it is presumably fixed. A quick test on a couple of rates for me, seems to give values that are OK, on the current versions.

Best Wishes
russr



Joined: 24 May 2005
Posts: 8
Location: New Jersey

View user's profile Send private message Visit poster's website

PostPosted: Fri Feb 17, 2006 10:16 am     Reply with quote

I emailed their tech support and sent them my .LST file. I think they were able to confirm the problem as they are emailing me the latest version of the compiler.

I only hope the latest version does not introduce additional bugs.
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