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

UART not work on 18F14k50

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



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

UART not work on 18F14k50
PostPosted: Wed Jul 14, 2010 7:13 am     Reply with quote

hello I wrote this simple program to send via UART any text ... why not working?

Code:
#include <18F14K50.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                   
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV19               
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOMCLR                     //Master Clear pin disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES HFOFST               
#FUSES NOWRT0               
#FUSES NOWRT1               
#FUSES USBDIV1             
#FUSES BBSIZ2K                  //2K words Boot Block size
#FUSES CPUDIV1
#FUSES PLLEN           
#FUSES PCLKEN     
#use delay(clock=48000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1)


void main()
{

 
printf("hello");

while(true);

}


I use a real 12MHz quartz and multiplies it with CPUDIV 48MHz ... I try the firmware with proteus simulation but does not work ... why? everything has always worked ...
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 10:30 am     Reply with quote

What's wrong? nobody knows the solution? I have a problem in the fuses? Crying or Very sad
I also tried the pic actually mounting the circuit but have not received anything from the UART ...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 12:12 pm     Reply with quote

First try it with #use delay() set to 12 MHz, and use the HS fuse.
Disable the PLL. Get it running at 12 MHz initially.
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 12:16 pm     Reply with quote

ok I do the test immediately
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 12:22 pm     Reply with quote

I modified so it does not work the same ... my version of the compiler is 4.106 and I use the PCH16 ...
Code:

#include <18F14K50.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                   
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV19               
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES IESO                     //Internal External Switch Over mode enabled
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOMCLR                     //Master Clear pin disabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPB                    //No Boot Block code protection
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES HFOFST               
#FUSES NOWRT0               
#FUSES NOWRT1               
#FUSES USBDIV1             
#FUSES BBSIZ2K                  //2K words Boot Block size
#FUSES CPUDIV1
//#FUSES PLLEN           
#FUSES PCLKEN           
#use delay(clock=12000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1)


void main()
{

 
printf("ciao");

while(true);
}
denis_11



Joined: 13 Jul 2010
Posts: 45

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 12:29 pm     Reply with quote

solved ... I had to change the pins for UART because those pins are used for USB ... thanks! Very Happy

Last edited by denis_11 on Wed Jul 14, 2010 12:30 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 14, 2010 12:30 pm     Reply with quote

Quote:

#use rs232(baud=9600,parity=N,xmit=PIN_A0,rcv=PIN_A1)

I just looked at the data sheet for the 18F14K50. Pins A0 and A1 are
not capable of doing digital output. They can only do input. When
you see the D+ and D- labels on the pins in the data sheet, this should
be a clue that there is something unusual about these pins. In fact,
these are the USB pins. Microchip doesn't allow these pins to ever do
digital output. They can only do input. That's why you can not transmit
data on pin A0. Solution: Choose some different pins.

Look in this section of the data sheet to see the capability of the pins:
Quote:

TABLE 1-2: PIC18F1XK50/PIC18LF1XK50 PINOUT I/O DESCRIPTIONS
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