View previous topic :: View next topic |
Author |
Message |
ep.hobbyiest
Joined: 08 Oct 2014 Posts: 20
|
UART not working 18f25k22 |
Posted: Sat Sep 09, 2017 1:56 am |
|
|
Hi,
I am using pic18f25k22 PIC. Code is working on proteus but not on real hardware.
Led blinking is working properly on hardware.
Here is the code.
Code: | #include <main.h>
void main()
{
while(TRUE)
{
//TODO: User Code
printf("Live\r\n");
delay_ms(1000);
}
} |
and main.h file is as
Code: | #include <18F25K22.h>
#device ADC=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#use delay(internal=16MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1) |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Sat Sep 09, 2017 4:58 am |
|
|
Normally you will not get too many responses with 'Proteus' related questions. See PIC101.
My guess is that you've assigned the UART to a 'stream' AND you don't tell 'printf' to use that 'stream', so the PIC doesn't send data to whatever is attached to the PIC's UART pins. Not too sure where it goes but the listing would say.
Whenever you have project open, press F11, and the CCS C manual will 'popup'! Then you can quickly search and read about the various features and functions and syntax.
As you just found out Proteus does NOT work properly !! Even for SIMPLE code, it FAILS.
Jay |
|
|
ep.hobbyiest
Joined: 08 Oct 2014 Posts: 20
|
|
Posted: Sat Sep 09, 2017 5:32 am |
|
|
Thanks. It worked. I checked the manual and i saw printf. So, i just use same printf function as normal stdio.h includes. |
|
|
|