![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
Typemod using custom external ram functions |
Posted: Thu Apr 20, 2006 2:38 pm |
|
|
PCWH R3.249 I am seeing a typemod bug I can't explain.
I am using typemod for access to external memory as shown here.
http://www.ccsinfo.com/faq.php?page=addressmod
I made shell read and write functions.
The write function just prints the proposed data.
If I put in a line for "record2" I see expected data.
If I take that line out, I don't see the expected data.
Does anyone understand whats going on here?
Code: | #include <18F452.H>
#use delay(clock=40000000)
#fuses h4,nowdt,noprotect,nolvp
#use rs232(baud=19200,xmit=PIN_C0,invert,stream=DEBUG,disable_ints) // stderr(same as debug)
#case
#zero_ram
//---------------------------------------------
mr(int32 addr,int8 *data,int8 size);
mw(int32 addr,int8 *data,int8 size);
//---------------------------------------------
typemod <,mr,mw,0x0000,0xFFFF>RAM;//24 bit address ,16 bit range
//---------------------------------------------
struct rec_struc //rec definition
{
int16 pc;
int16 ai;
int8 tz;
}RAM record;
int16 RAM record2;
//====================================================================//
void main(void)
{
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(0);set_tris_e(0);
printf("Start\n\r");
record.pc=0x1122;
record.ai=0x3344;
record.tz=0x55;
record2 =0x6677; //<----------------Take out this line and it BLOWS up
printf("DONE !\n\r");
while(1)
{
}
}
//======================multi_write===========================//
mw(int32 addr,int8 *data,int8 size)
{
int8 x;
int32 start_size;
start_size=size;
fprintf(DEBUG,"write addr=%lu s=%u ",addr,size);
for(x=0;x<size;x++,data++){
fprintf(DEBUG,"0x%X,",*data);
}
fprintf(DEBUG,"\n\r");
return(TRUE);
}
//======================multi_read===========================//
mr(int32 addr,int8 *data,int8 size){
}
|
Code: |
//--BAD--
write addr=0 s=2 0x22,0x00,
write addr=2 s=2 0x44,0x02,
write addr=4 s=1 0x55,
|
Code: |
//--Good--
write addr=0 s=2 0x22,0x11,
write addr=2 s=2 0x44,0x33,
write addr=4 s=1 0x55,
write addr=5 s=2 0x77,0x66,
|
Last edited by treitmey on Thu Apr 20, 2006 3:46 pm; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Apr 20, 2006 3:34 pm |
|
|
Quote: | struct rec_struc //rec definition
{
int16 pc;
int16 ai;
int8 tz;
}RAM record;
int16 RAM record2; |
One thing you might try is to take the "record" declaration out
of the structure and typdef the structure instead. Then use the
type to declare "record" on a separate line of code. I haven't
tested this but it's something to try. The way you describe the
problem implies that possibly CCS is looking for a typedef, and
they may have only tested it in that manner. |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Apr 20, 2006 3:50 pm |
|
|
Thanks
Seems to work. Doesn't give me a "warm fuzzy" feeling tho.
Code: | #include <18F452.H>
#use delay(clock=40000000)
#fuses h4,nowdt,noprotect,nolvp
#use rs232(baud=19200,xmit=PIN_C0,invert,stream=DEBUG,disable_ints) // stderr(same as debug)
#case
#zero_ram
int8 ERRORS;
#define FRAM_CHIPS 4
//-------prototype-------------------------------
mr(int32 addr,int8 *data,int8 size);
mw(int32 addr,int8 *data,int8 size);
//---------------------------------------------
typemod <,mr,mw,0x0000,0xFFFF>RAM;//24 bit address ,16 bit range
//---------------------------------------------
struct rec_struc //rec definition
{
int16 pc;
int16 ai;
int8 tz;
};
//====================================================================//
void main(void)
{
struct rec_struc RAM record;
setup_adc_ports(NO_ANALOGS);
set_tris_a(0);set_tris_b(0);set_tris_c(0);set_tris_d(0);set_tris_e(0);
printf("Start\n\r");
record.pc=0xBBAA;
record.ai=0xDDCC;
record.tz=0xFF;
printf("DONE !\n\r");
while(1)
{
}
}
//======================multi_write===========================//
mw(int32 addr,int8 *data,int8 size)
{
int8 x;
int32 start_size;
start_size=size;
fprintf(DEBUG,"write addr=%lu s=%u ",addr,size);
for(x=0;x<size;x++,data++){
fprintf(DEBUG,"0x%X,",*data);
}
fprintf(DEBUG,"\n\r");
return(TRUE);
}
//======================multi_read===========================//
mr(int32 addr,int8 *data,int8 size){
} |
I responded so fast, cause I came to that same conclusion. Didn't know why it acted like that tho. |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Thu Apr 20, 2006 4:08 pm |
|
|
BTW:
#byte and #locate will also screw up typemod variables
It looks like the compiler understands the use,.. but the second
byte of data transfered is corrupted again. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|