View previous topic :: View next topic |
Author |
Message |
denis_11
Joined: 13 Jul 2010 Posts: 45
|
UART not work on 18F14k50 |
Posted: Wed Jul 14, 2010 7:13 am |
|
|
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
|
|
Posted: Wed Jul 14, 2010 10:30 am |
|
|
What's wrong? nobody knows the solution? I have a problem in the fuses?
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
|
|
Posted: Wed Jul 14, 2010 12:12 pm |
|
|
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
|
|
Posted: Wed Jul 14, 2010 12:16 pm |
|
|
ok I do the test immediately |
|
|
denis_11
Joined: 13 Jul 2010 Posts: 45
|
|
Posted: Wed Jul 14, 2010 12:22 pm |
|
|
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
|
|
Posted: Wed Jul 14, 2010 12:29 pm |
|
|
solved ... I had to change the pins for UART because those pins are used for USB ... thanks!
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
|
|
Posted: Wed Jul 14, 2010 12:30 pm |
|
|
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 |
|
|
|
|