Error using bitand - Double inputs must have integer values in the integer range when mixed with integer inputs.
Show older comments
I'm having an issue regarding the bitand() function. I'm getting an error when I'm running the code. below is just a section of the code I'm running.
properties
SLEEP = hex2dec('10');
function
mode1 = r.i2c.readRegister(r.MODE1); %this is being read as a value of 1
mode1 = bitand(mode1, bitcmp(r.SLEEP, 'int8')); %here is where the error is occurring.
this is what pops up.
Error using bitand
Double inputs must have integer values in the integer range when mixed with integer inputs.
Error in PWM (line 50)
mode1 = bitand(mode1, bitcmp(r.SLEEP, 'int8'));
Error in MotorHat (line 22)
motor_obj.pwm = PWM(motor_obj.rpi, addr);
now if I run just bitcmp(r.SLEEP, 'int8') on its own the value is -17. I have to run it with the assumed type 'int8', because it comes back as a double value 1.8447e+19 if I don't.
anyone have any ideas as to what the issue is and how I can go about fixing it?
If i do the following
bitand(1, -17, 'int8')
i get the answer of 1. Which would be the answer I'm looking for. but for obvious reasons, I can't just insert values, I need to be able to use the variables.
4 Comments
Walter Roberson
on 13 Apr 2017
After you read from the register, what shows up if you calculate
model - 1.0
I predict that the answer will not be exactly 0
Michael
on 14 Apr 2017
Michael
on 14 Apr 2017
Walter Roberson
on 14 Apr 2017
Is it possible that some of the values are >= 128 ? That would cause confusion between uint8 and int8 .
Answers (0)
Categories
Find more on Frequency Transformations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!