View previous topic :: View next topic |
Author |
Message |
david Guest
|
long int test |
Posted: Mon Nov 01, 2004 9:38 am |
|
|
When I do a test like
if(x == 0x3456)
where x is an unsigned long int I find this test is true when x == 0x0056.
The upper byte is a don't care. How do I do the test such that the entire value is tested? |
|
|
rnielsen
Joined: 23 Sep 2003 Posts: 852 Location: Utah
|
|
Posted: Mon Nov 01, 2004 9:58 am |
|
|
Well, if you are declaring x as
int x;
then x will be able to hold a value of 0 - 255. The declaration 'int' is the same as declaring int8, or an eight bit variable. By doing this:
int16 x;
this will make it an unsigned 16 bit integer that can now hold a value of 0 - 65535. These default to unsigned variables. If you want to make it so you can store negative numbers then you need to declare it like;
signed int8 x;
signed int16 x;
See if that will make a difference.
Ronald |
|
|
david Guest
|
problem was a bug |
Posted: Tue Nov 02, 2004 2:13 pm |
|
|
I've tried everything to typecast and make this if statement test the entire 16 bit value to no avail. The problem appears only when I run the design in the mplab simulator. When I run the design in hardware it works fine. I expect an hour delay and the hardware does it. In the simulator the lower 8 bits are tested only and I get a 14 minute delay. I had another problem with timer0 which showed up in the simulator but not in the hardware. Now I'm concerned that CCS and the mplab simulator is full of bugs and can't be trusted. I like to do developement on a laptop and run the simulator. I really like what CCS has to offer but I may be forced to go with C18. Any opinions from the experienced please? Thanks, |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Tue Nov 02, 2004 4:05 pm |
|
|
Get on the Microchip forum and post this problem. _________________ David |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Tue Nov 02, 2004 6:58 pm |
|
|
Look at the lst file and see what is going on. Also, step through the code to gain more insight. |
|
|
david Guest
|
mplab is the problem |
Posted: Wed Nov 03, 2004 2:01 pm |
|
|
just talked with a C18 developer and was told he sees the same bug so MPLAB is the culprit. |
|
|
|