View previous topic :: View next topic |
Author |
Message |
Rocky
Joined: 26 Apr 2009 Posts: 22 Location: USA
|
PCD: compatibility problem |
Posted: Tue May 12, 2009 6:04 pm |
|
|
Hello.
I wrote a program for a pic24 that compiles and works correctly with the Microchip compiler. Now that I bought the CCS compiler I am converting the program and finding problems. Some I was able to correct (int x= 0; gives an error. Changed to int x; x=0;)
but others I don't. One of them is:
Code: | unsigned char *FontTable[] =
{
(unsigned char*)FONT6x8,
(unsigned char *)FONT8x8,
(unsigned char *)FONT8x16
};
// get pointer to the beginning of the selected font table
pFont = (unsigned char*)FontTable[size]; |
It highlights the first ( and gives an error: Bad Expression Syntax.
Anyone knows what the problem could be?
Thank you. _________________ PERSEVERANCE IS THE KEY TO SUCCESS |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 12, 2009 11:12 pm |
|
|
You didn't provide a test program, so I made the one below.
I don't have PCD so I tested it with the PCH compiler.
With the changes shown below it compiles, and displays the
following output, which is correct.
I suggest that the first thing you should do, is to explicitly declare
the number of elements in the FontTable array, as shown below.
Code: |
#include <18F452.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
unsigned char FONT6x8[2] = {0x01, 0x02};
unsigned char FONT8x8[2] = {0x03, 0x04};
unsigned char FONT8x16[2] = {0x05, 0x06};
#define NUM_FONT_TABLES 3
unsigned char *FontTable[NUM_FONT_TABLES] =
{
(unsigned char*)FONT6x8,
(unsigned char*)FONT8x8,
(unsigned char*)FONT8x16
};
//====================================
void main()
{
char *pFont;
int8 size;
for(size = 0; size < NUM_FONT_TABLES; size++)
{
pFont = (unsigned char*)FontTable[size];
printf("%X %X \n\r", *pFont, *(pFont +1) );
}
while(1);
}
|
|
|
|
Rocky
Joined: 26 Apr 2009 Posts: 22 Location: USA
|
PCD: compatibility problem |
Posted: Wed May 13, 2009 12:57 am |
|
|
Thank you PCM.
Declaring the number of the font table elements removed the error but now I get "Expression must evaluate to a constant" on the line:
(unsigned char*)FONT6x8,
despite it is declared as a constant in "fonts.h":
const unsigned char FONT6x8[97][8] = {
0x06,0x08,0x08,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
...
Still, I don't understand why it brings errors in CCS while it compiles correctly under GCC. _________________ PERSEVERANCE IS THE KEY TO SUCCESS |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed May 13, 2009 1:17 am |
|
|
Traditionally, CCS doesn't support pointers to constants. I don't have
PCD, so I can't test if this is still true with that compiler. For that reason,
I can't give any more help on this. |
|
|
Guest
|
PCD: Compatibility problem |
Posted: Wed May 13, 2009 10:35 am |
|
|
it looks like PCD doesn't accept pointer to constant just like PCM.
I removed 'const' from the font table definition and now I get an error:
'attempt to create a pointer to a const' for each call to the LCDPutStr(*pstring, ...) function. That function itself calls 'LCDPutChar(*pstring++, ...).
However, I looked at the CCS drivers and found the use of constants for fonts tables. i.e. GLCD.c
I am going to combine my program, adapt CCS's driver to it and see if I can make it work.
Thank you for the help PCM. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed May 13, 2009 1:20 pm |
|
|
PCD accepts rom constants using the syntax suggested in readme.txt without reporting errors. But the code don't work. The addresses are not copied to FontTable and no TBLRD code is generated to read data from the rom.
With PIC18, the code seems to work almost, except for *(pfont+1), that doesn't return the correct character, at least with MPLAB SIM. |
|
|
Rocky
Joined: 26 Apr 2009 Posts: 22 Location: USA
|
PCD compatibility |
Posted: Wed May 13, 2009 4:10 pm |
|
|
I start wondering if it was such a good idea to buy the CCS tools.
Tomorrow I am flying to a customer and need to have my demo running.
As the program is working under the Microchip compiler and need only one function to be added I'll finish it that way and will look further when I get back.
I'll post any success (or failure).
Thanks to everybody. _________________ PERSEVERANCE IS THE KEY TO SUCCESS |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed May 13, 2009 4:36 pm |
|
|
It seems that rom pointers are still not operational with recent PCD versions. You can define a rom pointer in ram, but it's implemented by PCD as a 16 bit variable and loaded only with the low word of the respective rom address.
Code: | rom unsigned char *FontTable[NUM_FONT_TABLES];
FontTable[0]=FONT6x8; |
And rom pointers are apparently not dereferenced by TBLRD code, as it's done in PCH. Looks like a building site. |
|
|
Rocky
Joined: 26 Apr 2009 Posts: 22 Location: USA
|
|
Posted: Wed May 13, 2009 6:28 pm |
|
|
thank you I'll try next week. _________________ PERSEVERANCE IS THE KEY TO SUCCESS |
|
|
Rocky
Joined: 26 Apr 2009 Posts: 22 Location: USA
|
PCD compatibility |
Posted: Thu Jul 23, 2009 5:34 pm |
|
|
Been busy and forgot to post the result.
FvM that worked, thank you very much for the help.
Rock _________________ PERSEVERANCE IS THE KEY TO SUCCESS |
|
|
|