|
|
View previous topic :: View next topic |
Author |
Message |
Triton1020
Joined: 07 Oct 2005 Posts: 5
|
PCH Program Execution Order |
Posted: Fri Oct 07, 2005 1:55 pm |
|
|
Hello,
I am new to this forum and to PIC programming. I have wrote a simple piece of code to enter a character into digit one of an LCD. The problem is, when I begin to modify the code by adding statements or by eliminating an unecessary function call, the program doesn't work any more. I have noticed that if I single step through the code, the "working" version steps through correctly and the "non-working" version jumps to the middle of the program and does not initialize properly. I have attached code showing the simplest manifestation. The first program calls LCD_Init() from a second file, and the second non-functioning program simply sets up the LCD directly. I can also cause this by adding SWITCH statements or if/else statements. Any help would be greatly appreciated.
LCD_Driver file:
#include "LCD_Driver.h"
#include "LCD_Init.c"
#define Digit_1_MSB COM0+0,COM1+0,COM2+0,COM3+3,COM2+3,COM1+3,COM1+2,COM0+2
#define Digit_1_LSB COM0+1,COM1+1,COM2+1,COM2+2,COM3+2,COM3+1,COM3+0
void main()
{
LCD_Init();
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
LCD_Symbol(0xEE, Digit_1_MSB);
LCD_Symbol(0x20, Digit_1_LSB);
}
LCD_Init file:
void LCD_Init(void)
{
setup_lcd(lcd_mux14,0);
return;
}
LCD_DRIVER (non-functioning)
void main()
{
setup_lcd(lcd_mux14,0);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
LCD_Symbol(0xEE, Digit_1_MSB);
LCD_Symbol(0x20, Digit_1_LSB);
} _________________ Regards,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Oct 07, 2005 2:13 pm |
|
|
1. What PIC are you using ?
2. Post your #fuses statement.
3. Post your compiler version. This will be a number such as 3.191
or 3.235, etc., and can be found at the start of the .LST file in your
project folder.
These things may show me the problem (or a problem).
But you've got several little weird things in your program.
1. You're letting the program fall off the end of main()
where it will hit the hidden SLEEP instruction which is
placed there by CCS.
2. You've got a "return" statement at the end of a routine
which has no return value. But the routine will automatically
return. No "return" statement is required.
Those might be small things but to me they set off a red flag
that you've got other stuff in your program (not posted) that
may be causing problems. |
|
|
Triton1020
Joined: 07 Oct 2005 Posts: 5
|
|
Posted: Tue Oct 11, 2005 8:48 am |
|
|
Thanks for the patience. As you have gleened, I am an inexperienced programmer. I appreciate the tips. The info you requested:
1. PIC18F8490
2. #include <18F8490.h>
#device adc=8
#use delay(clock=8000000)
#fuses NOWDT,WDT128,NOPROTECT, BROWNOUT, BORV21, NOPUT, IESO, STVREN, NODEBUG, FCMEN, MCLR, LPT1OSC, XINST
3. PCH Version 3.235
I am using the PIC18F8490 LCD Demo board for testing. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Oct 11, 2005 12:41 pm |
|
|
1. I don't see an oscillator setting in your #fuses statement, such as
HS or INTRC_IO. You should add one.
2. Normally, the #use delay() statement is placed after the #fuses
statement. If you use INTRC or INTRC_IO, and you place the
#use delay() statement after the #fuses statement, the compiler
will automatically insert code to setup the internal oscillator for the
specified frequency. Example:
#fuses INTRC_IO // Other fuses not shown
#use delay(clock=8000000)
3. Change the XINST fuse to NOXINST. See the last post in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=21251&highlight=xinst |
|
|
Triton1020
Joined: 07 Oct 2005 Posts: 5
|
|
Posted: Wed Oct 12, 2005 9:28 am |
|
|
That seems to have fixed the execution order if I single step. However, when I reach the "setup_lcd" function in the non-functioning code, it doesn't initialize the LCD. If I try and add a SWITCH or an IF statement, I am back to the execution order being all messed up.
A couple of things to note:
- When I use the wizard, it sets up PSP_Disabled, but the compiler does not recognize this function.
- If I try to use the INTRC fuse, the compiler does not recognize this either. _________________ Regards,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 12, 2005 9:45 am |
|
|
Quote: | If I try to use the INTRC fuse, the compiler does not recognize this either. |
I just compiled the following program with the INTRC fuse with PCH
vs. 3.235 and it compiled with no errors.
Code: | #include <18F8490.H>
#fuses INTRC, NOWDT, NOPROTECT, BROWNOUT, PUT
#use delay(clock=8000000)
void main()
{
while(1);
} |
|
|
|
Triton1020
Joined: 07 Oct 2005 Posts: 5
|
|
Posted: Wed Oct 12, 2005 9:56 am |
|
|
I just copied your program into a new file and got the compiler error:
Unknown keyword in #FUSES "0x08". If I change the fuse to INTRC_IO, it compiles fine.
I believe the computer that I am using had an old version compiler for a PIC 16. I purchased the latest PCH to allow PIC18 capability. I wonder if the 2 programs are interacting? I'll try removing everything and reloading. _________________ Regards,
John |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 12, 2005 10:11 am |
|
|
Right. You can't mix versions of the PCM and PCH. The last one
that is installed is the one that works. You might be able to get
away with not re-installing each one before you use it, if the version
numbers are close and if CCS didn't change Devices.dat too much
between the versions.
Here is what Darren had to say on the topic:
Quote: |
I think one problem is devices.dat. PCM and PCH share the same
devices.dat file. The problem is that the format of this file may change
with different releases. So if you have two different versions installed in
the same directory, devices.dat may be the right one for one version but
won't work for another. |
We've gone over this issue many times on here. It doesn't apply
to PCW or PCWH, because you automatically get the same version
of each compiler with those products. It's only an issue if you
buy PCM or PCH as separate compilers.
Mark came up with a complicated method to fix this problem which
involves editing the Windows Registry I didn't want to do that so
I just bought the maintenance on PCH (I already had it on PCM),
so that I can have the same version of each compiler in my
c:\Program Files\Picc directory. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Oct 12, 2005 11:07 am |
|
|
Quote: | Mark came up with a complicated method to fix this problem which
involves editing the Windows Registry I didn't want to do that |
Chicken |
|
|
Triton1020
Joined: 07 Oct 2005 Posts: 5
|
|
Posted: Wed Oct 12, 2005 11:57 am |
|
|
That was it! I unistalled the old version and reinstalled PCH w/updates and everything works as expected. Of course, now I can't use the editor which kind of stinks, but I can live with that.
Thank you very much for your help. _________________ Regards,
John |
|
|
adrian
Joined: 08 Sep 2003 Posts: 92 Location: Glasgow, UK
|
|
Posted: Thu Oct 13, 2005 5:35 am |
|
|
Triton1020 wrote: | I just copied your program into a new file and got the compiler error:
Unknown keyword in #FUSES "0x08". If I change the fuse to INTRC_IO, it compiles fine. |
I found this exact problem in PCM v3.233 for the 16F913, which was solved by Mark at CCS. You need to edit the .h file as follows:
Quote: | This message is a reply to CCS e-mail id: 5I4387
In the 16F913.H file change INTRC to LCD_INTRC
|
This was fixed in v3.234 |
|
|
|
|
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
|