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

USART on PIC16F1947

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



Joined: 11 Dec 2011
Posts: 11
Location: Thailand

View user's profile Send private message

USART on PIC16F1947
PostPosted: Sat Jan 14, 2012 8:30 am     Reply with quote

Hello. If run 16F1947 at xtal 32MHz, USART error.
If run at xtal 8MHz or 4MHz USART work.
Code:

#include <16F1947.h>

#fuses INTRC_IO,NOWDT,BROWNOUT,PUT
#use delay(clock=32M)
#use rs232(baud=9600, UART1, ERRORS)

int8 i;
int16 cnt;               
#define delay_ms(x)            \
cnt = x;                              \
   while(cnt)                         \
       {                                 \
       for(i=0; i<8; i++)          \
          {                              \
           delay_cycles(250);    \
           delay_cycles(250);    \
           delay_cycles(250);    \
           delay_cycles(250);    \
          }                             \
       cnt--;                          \
       }
 
//====================================
void main()
{
   int8 c;
   
   printf("Start \n\r");

   while(TRUE)
   {
      c = getc();
      putc(c);
   }   
}
 

This code gives USART error.
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 10:01 am     Reply with quote

You have not setup the oscillator section ( the 'clock' ) correctly for 32MHz operation.

Please read the datasheet, and look at the diagram showing how the PIC can be configured for various 'clocks'.

The solution involves configuring the PLL into the clock section.
Noland



Joined: 11 Dec 2011
Posts: 11
Location: Thailand

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 12:00 pm     Reply with quote

the datasheet, page66

5.2.2.5 Internal Oscillator Frequency
Selection

32 MHz (requires 4X PLL)

but from http://www.ccsinfo.com/forum/viewtopic.php?p=154871#154871 Post reply by PCM programmer using, that code USART WORK

Code:
#include <16F1823.H>
#fuses INTRC_IO,NOWDT,NOPROTECT,MCLR
#use delay(clock=32M) 


What is so? the datasheet 16f1823 page61 Internal Oscillator Frequency 32 MHz (requires 4X PLL)
temtronic



Joined: 01 Jul 2010
Posts: 9244
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Jan 14, 2012 2:23 pm     Reply with quote

Those are two different PICs.......
You have to configure your PIC as per IT'S datasheet...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 16, 2012 2:37 pm     Reply with quote

If you need help with the UART on the 16F1947, then post your compiler version.

Also, in your post you refer to "xtal", which means a crystal, which means
this:
http://media.digikey.com/photos/ECS%20Photos/HC-49US.jpg
But your code shows "INTRC_IO" which is the internal oscillator, and does
not use a crystal.

But to repeat, make sure you post your compiler version.
Noland



Joined: 11 Dec 2011
Posts: 11
Location: Thailand

View user's profile Send private message

PostPosted: Sun Jan 22, 2012 9:46 pm     Reply with quote

CCS V4.107
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jan 23, 2012 10:56 pm     Reply with quote

I was unable to make my 16F1947 breadboard work. Without that board,
it's not nearly as easy to find the problem. So I think I'm going to give up
on this problem. I'm just too busy at work to spend any more time on it.
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