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

RS-232 PIC16F1827

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



Joined: 10 Feb 2010
Posts: 9

View user's profile Send private message

RS-232 PIC16F1827
PostPosted: Mon Mar 01, 2010 12:17 am     Reply with quote

Hi,

I have written a test program but I have problem trying to transmitting out correctly to my PC's COM port using rs-232.

The hyperterminal output shows
Quote:
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€
€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€

My test program
Code:

#include <16F1827.h>
#include <stdio.h>

#use delay(clock = 4000000)
#use rs232(baud=38400, xmit=PIN_B5, rcv=PIN_B2, PARITY=N, BITS=8, STOP=1)
#fuses INTRC_IO, NOWDT, BROWNOUT, NOMCLR

void main(void)
{   
   while(1)
   {   
      printf("Testing123");

   }

}

I am using the internal oscillator, with baudrate set to 38400. I captured the TX data pin on the scope and found that 1 bit period is about 4.4kHz instead of 38.4KHz.

Anybody can help?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 12:57 am     Reply with quote

Did you set Hyperterminal to 38400 baud ?

This is a new, enhanced 16F-series PIC. It's possible there are bugs
in the compiler. What's your compiler version ?
TCC



Joined: 10 Feb 2010
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 1:07 am     Reply with quote

Yes, my setting in HyperTerminal is correct.

I complied with MPLAB, PCM version 4.105
Ttelmah
Guest







PostPosted: Mon Mar 01, 2010 3:13 am     Reply with quote

The discrepancy, looks suspiciously like a factor of 8*.
Prove that your chip is running at 4MHz. Do the simple 'set a pin high', pause for half a second, set it low, pause again, repeat. Verify that you do see 1Hz. It is possible that the actual problem is the compiler setting up the oscillator wrong, and you are actually running at 500KHz.....
There is nothing in the UART section, that easily gives a factor of 8* error (the difference between the two prescalers is a factor of 4*), and the BRG calculation is the same as for most older chips. I'd be very suspicious that the oscillator may be the actual problem....
500KHz, is the _default_ setting of this chips oscillator. I suspect that the compiler is not changing the prescaler properly.
If it is running at 500K, you might try a separate 'setup_oscillator' line, or just set the prescaler yourself, while moaning at CCS....

Best Wishes
TCC



Joined: 10 Feb 2010
Posts: 9

View user's profile Send private message

PostPosted: Mon Mar 01, 2010 7:36 pm     Reply with quote

Hi Ttelmah

Thanks for your suggestion, i have a line 'setup_oscillator(OSC_4MHZ)' and it work slightly better..but it still output garbage.

I measured the bit rate from the scope and found that low bit is 38.4KHz but high bit is 33.6KHz which does not tally with my baudrate.

Any further suggestion?
TCC



Joined: 10 Feb 2010
Posts: 9

View user's profile Send private message

PostPosted: Tue Mar 02, 2010 3:52 am     Reply with quote

Hi,

When running with external crystal (in HS mode), I found that the timing of this 1827 chip is always 4x faster of my settings.

For example, during delay_ms(500), i am getting 125ms instead of 500ms, my baud rate also 4x faster.

Please advice.
Ttelmah
Guest







PostPosted: Tue Mar 02, 2010 4:08 am     Reply with quote

Implies the PLL is getting turned on.....
Unfortunately, if this is turned 'on' in the fuses, it can't be turned off using the software enable/disable.
Does your programmer have the ability for you to look at/set the fuses from it's control window?. If so, sit down, and make a list of how the fuses should be set, qand manually change them here. If it then works, you know exactly what the problem is.....
It looks as if the fuse settings for this chip are completely screwed...

Best Wishes
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