I have a small-embedded system project that giving me trouble. It is small robot based on the Motorola 68HC12 (16 bit) microcontroller. Here is the deal:
//#### Define ####//
#define PWPER_01 *(int volatile *)(0x4C) //Channel 0/1
#define PWPER_23 *(int volatile *)(0x4E) //Channel 2/3
#define PWDTY_01 *(int volatile *)(0x50) //Channel 0/1
#define PWDTY_23 *(int volatile *)(0x52) //Channel 2/3
PWDTY_01 = (PWPER_01 - (PWPER_01/100)*(motor_DC));
"PWDTY_01" and "PWPER_01" are both 16 bit internal registers. "motor_DC" is a variable use in calculations. "PWPER_01" is about 40000 so is fairly close to the upper limit of a 16bit integer. "motor_DC" is an integer less that 100.
"PWDTY_01" is not coming out right. I think something exceeding the 16bit-interger space. I tried to order my operation to avoid overflowing the 16bit-interger space, but something is up.
Any ideas?
I'm developing the software in C.
geoff
//#### Define ####//
#define PWPER_01 *(int volatile *)(0x4C) //Channel 0/1
#define PWPER_23 *(int volatile *)(0x4E) //Channel 2/3
#define PWDTY_01 *(int volatile *)(0x50) //Channel 0/1
#define PWDTY_23 *(int volatile *)(0x52) //Channel 2/3
PWDTY_01 = (PWPER_01 - (PWPER_01/100)*(motor_DC));
"PWDTY_01" and "PWPER_01" are both 16 bit internal registers. "motor_DC" is a variable use in calculations. "PWPER_01" is about 40000 so is fairly close to the upper limit of a 16bit integer. "motor_DC" is an integer less that 100.
"PWDTY_01" is not coming out right. I think something exceeding the 16bit-interger space. I tried to order my operation to avoid overflowing the 16bit-interger space, but something is up.
Any ideas?
I'm developing the software in C.
geoff