Hello:
I have a strange problem in some functions. When I compile and simulate, the program does what it is suppose to. However, when I compile and emulate, it does not.
The issue arises in the passing wdata variable into the function memsw(). For example: In the function setpga() the variable pgaset is passed correctly to the memsw() function. In the function setanalsw(), the answsetup variable passed to the memsw() function is passed in as 0 (it simulates showing a pass of the correct value but, when run and debugged the value passed shows up as 0 and I can verify that the on board peripheal is not set)
Code:
void memsw(unsigned int Address, unsigned short wdata)
{
unsigned short* AddressP;
AddressP= setadd13_19(Address);
if (Address>=0x90000000 && Address<0x90040000){delay(0x00000100);}
*AddressP=wdata;
delay(0x0064); }
The code above works fine for the call from setpga() but does not work for setanalsw().
unsigned short setpga (unsigned short pga, unsigned short fs, unsigned short swoe)
{
unsigned short pgaset;
pgaset=pga;
pgaset=pgaset | (fs *4);
pgaset=pgaset | (swoe *8);
memsw(pga_fs_disp,pgaset);
return pgaset;
}
The code above works fine
void setanalsw(unsigned short ch1, unsigned short ch2, unsigned short gm)
{
unsigned short answsetup,x;
answsetup=ch1-1;
x=(ch2-1) * 8;
answsetup=answsetup | x;
x=gm * 64;
answsetup=answsetup | x;
memsw(analogch, answsetup);
}
The code above simulates fine but while running the processor does not interpret correctly.
I have verified that a direct write ie: memsw(anlogch,0x0048); will set the peripheal to the expected condition.
I am booting from EEPROM, and am going through the GENAIS step.
Any clue what may be happening here.