|
|
View previous topic :: View next topic |
Author |
Message |
kda406
Joined: 17 Sep 2003 Posts: 97 Location: Atlanta, GA, USA
|
make8() not working |
Posted: Thu Dec 09, 2010 2:02 pm |
|
|
4.114, PIC18F8722
Make8() will not compile when a variable is used as the offset. Here is an example I created that will not compile: Code: | void somefunction(void) {
int8 iData[4];
int32 lPortBit[] = { 0x00000010,0x000000020,0x00000040,0x00000080,0x00000100,
0x00000001,0x00000002,0x00000004,0x00000008 };
int8 iCnt,iOffset;
for(iCnt=0;iCnt<9;iCnt++) {
for(iOffset=0;iOffset<3;iOffset++) iData[iOffset] = make8(lPortBit[iCnt],iOffset);
fprintf(TERM,"%02X\n\r",iData[0]
}
} | This would make iData[3] contain the MSB and iData[0] contain the LSB of the int32.
Quote: | *** Error 108 "AB12-IO.c" Line 121(39,46): Invalid parameters to built in function :: | where line 121 is the line with make8() in it.
The CCS manual does not indicate if offset must be a constant. Am I doing something wrong?
Thanks,
Kyle |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 09, 2010 2:12 pm |
|
|
I don't think a variable parameter is supported for the offset. |
|
|
kda406
Joined: 17 Sep 2003 Posts: 97 Location: Atlanta, GA, USA
|
|
Posted: Thu Dec 09, 2010 2:32 pm |
|
|
Thanks, that was my conclusion, but I don't see why they would not. It seems sophomoric to do: Code: | iData[0] = make8(lPortBit[iCnt],0);
iData[1] = make8(lPortBit[iCnt],1);
iData[2] = make8(lPortBit[iCnt],2);
iData[3] = make8(lPortBit[iCnt],3); | My professors would have laughed at me for forgetting how to do loops.
Thanks,
Kyle |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Thu Dec 09, 2010 3:52 pm |
|
|
The problem is down to the nature of the function. It uses the simplest approach, to select the byte _efficiently_ at compile time. You can do it with a loop, using a union, or casting an int8 pointer to the memory you want to transfer, _but_ the variable version, will probably be about 3 or 4 times the size of all four of the single byte transfers, and slower too...
Best Wishes |
|
|
|
|
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
|