![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Jesus Zm
Joined: 04 Jan 2015 Posts: 3
|
Compiler is not working |
Posted: Sun Jan 04, 2015 3:20 pm |
|
|
Hi, i used ccs when i was in college, and never had a problem. Now I'm trying to use it for my graduate courses, but i have a lot of problems. My code is good, i can compile and I load it to Proteus and it works great. But when i try to load it into the picdem 18, it doesn't work at all. I've loaded the examples codes to the picdem and it works great, but i try to load my programs and they not work. This is an example, a simple blink program:
Code: | #include <18LF8722.h>
#device ADC=10
#use delay(crystal=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=PORT1)
#include <lcd.c>
void main()
{
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_6);
//lcd_init();
SET_TRIS_D(0X00);
while(TRUE)
{
OUTPUT_D(0XFF);
DELAY_MS(100);
OUTPUT_D(0X00);
DELAY_MS(100);
}
|
it works only when i quit the lcd_init() code.
I can't use lcd, rs232, and adc, i only can blink leds. I do have programming skills in ccs. I'm using version 5 demo. I hope you can help me.
PS, all the codes works properly in Proteus but not in the PICDEM.
Thanks |
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Sun Jan 04, 2015 3:30 pm |
|
|
Two things;
1. where is the fuses line? (it goes right after the device definition)
2. The lcd_init() likely hangs because you have the r/w line defined
Proteus is a lousy emulator and doesn't care about these things but
REAL HARDWARE does. _________________ Google and Forum Search are some of your best tools!!!! |
|
![](templates/subSilver/images/spacer.gif) |
gpsmikey
Joined: 16 Nov 2010 Posts: 588 Location: Kirkland, WA
|
|
Posted: Sun Jan 04, 2015 3:58 pm |
|
|
You will also typically need a 500ms delay or so BEFORE lcd_init() since it takes time to wake up before it will take commands.
mikey _________________ mikey
-- you can't have too many gadgets or too much disk space !
old engineering saying: 1+1 = 3 for sufficiently large values of 1 or small values of 3 |
|
![](templates/subSilver/images/spacer.gif) |
Jesus Zm
Joined: 04 Jan 2015 Posts: 3
|
|
Posted: Sun Jan 04, 2015 10:32 pm |
|
|
dyeatman wrote: | Two things;
1. where is the fuses line? (it goes right after the device definition)
2. The lcd_init() likely hangs because you have the r/w line defined
Proteus is a lousy emulator and doesn't care about these things but
REAL HARDWARE does. |
it has all the fuses, ive programmed a 16f877a and it works great, the thing is with the pic 18. |
|
![](templates/subSilver/images/spacer.gif) |
Jesus Zm
Joined: 04 Jan 2015 Posts: 3
|
|
Posted: Sun Jan 04, 2015 10:32 pm |
|
|
gpsmikey wrote: | You will also typically need a 500ms delay or so BEFORE lcd_init() since it takes time to wake up before it will take commands.
mikey |
thanks, i did what you told me,still not working |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19368
|
|
Posted: Mon Jan 05, 2015 3:25 am |
|
|
Jesus Zm wrote: | dyeatman wrote: | Two things;
1. where is the fuses line? (it goes right after the device definition)
2. The lcd_init() likely hangs because you have the r/w line defined
Proteus is a lousy emulator and doesn't care about these things but
REAL HARDWARE does. |
it has all the fuses, ive programmed a 16f877a and it works great, the thing is with the pic 18. |
The output 'has' all the fuses set, but what are they set to.
The point is that on many of the older chips, except for the oscillator (which normally default to RC), the rest of the fuses 'default' to a running state. So long as you specify 'crystal', the compiler changes the oscillator, so they then work. On the later chips this is not the case. There are normally a minimum of three or four fuses that you must set, to get the chips to work as you want. Also some peripherals 'wake' enabled.
By default, the watchdog will be on. Also port D, will be set as PSP. Both will stop your code from working..... |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Mon Jan 05, 2015 6:20 am |
|
|
As Mr. T points out, it's about the fuses. Proteus doesn't care what they are set to, but a real PIC sure does!
While the compiler does 'default' fuses, WHO said they will be exactly what you want for this program? Defaults are one person's idea of how 'things' should be configured, never what you need. Murphy's Law!
With today's PICs having more fuses than instructions, I now have a fuses file that I include in the program. EVERY fuse is set/cleared as needed for the program.Initially they are a configuration that gets the 1Hz LED program to run.Called 'PICtype_fuses_base.h' this gives me a known set of working fuses.In the case of the 46K22, this means no WDT, no Protection,use internal RC at 64MHz,MCLR, etc. When a project needs something different than the 'base' configuration, the base is copied, recoded, saved as PICtype_project_fuses.h making it easy to follow. Instead of 30 lines of fuses in the main program , 1 line does it.easy on the eyes and it's KNOWN to work,saving time debugging.
I also do the same for the PIC's I/O pins. A simple file,'PICtype_pins_base.h' is created once.Then copied and modified as the project requires.Again, it cleans up the project, makes code easy to read and you KNOW how the PIC is setup.
Just an idea you might like to copy
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19368
|
|
Posted: Mon Jan 05, 2015 10:05 am |
|
|
It's worse than that....
The 'default' is normally for all fuses to be in their 'erased' state. The compiler doesn't actually set (clear) any by default. A lot of the old chips would run in this state (though usually not 'right'). Most of the new ones, won't. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|