|
|
View previous topic :: View next topic |
Author |
Message |
future
Joined: 14 May 2004 Posts: 330
|
More typemod limitations? |
Posted: Sat Jul 29, 2006 2:28 pm |
|
|
Hi all,
I've stripped down the program to show the problem, "typemoded" variables won't accept some operations.
Code: | #include "18f452.h"
#zero_ram
#opt 11
#use delay( clock=40000000 )
#fuses H4, CPD, WDT1, PUT, PROTECT, CPB, WRT, WRTC, NOLVP, BROWNOUT
void DATAEPROM_Write ( int32 addr, int8 *ram, int nbytes );
void DATAEPROM_Read ( int32 addr, int8 *ram, int nbytes );
typemod <, DATAEPROM_Read, DATAEPROM_Write, 0x00000000, 0x000000FF > DATAEPROM ;
void DATAEPROM_Write( int32 addr, int8 *ram, int nbytes ) //
{ //
// EEADDR = addr; //
// EEDATA = ram; //
// ...
}
void DATAEPROM_Read( int32 addr, int8 *ram, int nbytes ) //
{ //
// EEADDR = addr; //
// ...
}
struct
{
unsigned char test1;
unsigned char test2;
unsigned char test3;
unsigned char test4;
unsigned char test5;
unsigned char test6;
unsigned char test7;
}
DATAEPROM TestStruct;
main( void )
{
char temp;
TestStruct.test1 = 2;
Temp = TestStruct.test2 >>1;
} |
This seems to kill the advantages of using external ram. |
|
|
Ttelmah Guest
|
|
Posted: Sun Jul 30, 2006 2:39 am |
|
|
Use the #type declaration, rather than trying to allocate the structure as you show. The compiler seems to get confused when you use a 'typemod' declaration on more complex types. So:
Code: |
#type default=DATAEEPROM
struct
{
unsigned char test1;
unsigned char test2;
unsigned char test3;
unsigned char test4;
unsigned char test5;
unsigned char test6;
unsigned char test7;
} TestStruct;
#type default=
|
Makes it work.
Best Wishes |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sun Jul 30, 2006 11:42 am |
|
|
It still doesn't work, it should be DATAEPROM instead of DATAEEPROM. |
|
|
Ttelmah Guest
|
|
Posted: Sun Jul 30, 2006 2:29 pm |
|
|
Since the code uses 'EEDATA', I must admit I changed it to refer to EEPROM. :-)
The odder thing, is that I actually compiled a demo, and looked through the code, and it appeared 'sensible', but now it refuses to compile like your earlier attempt. It appears that the return must be fed to a temporary register, rather than handled directly. A small limitation, but one that seems unnecessary, you would think that the normal 'scratch' process should handle this...
Best Wishes |
|
|
future
Joined: 14 May 2004 Posts: 330
|
|
Posted: Sun Jul 30, 2006 2:57 pm |
|
|
If I change the struct for an array and #define names for the variables it works. The result is ugly but does the job.
char TestArray[7];
#define test1 0
#define test1 1
...
TestStruct.test1 turns to TestArray[test1] |
|
|
|
|
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
|