CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

More typemod limitations?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

More typemod limitations?
PostPosted: Sat Jul 29, 2006 2:28 pm     Reply with quote

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







PostPosted: Sun Jul 30, 2006 2:39 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jul 30, 2006 11:42 am     Reply with quote

It still doesn't work, it should be DATAEPROM instead of DATAEEPROM.
Ttelmah
Guest







PostPosted: Sun Jul 30, 2006 2:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Jul 30, 2006 2:57 pm     Reply with quote

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]
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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