Quantcast
Channel: SparkFun Electronics Comments
Viewing all articles
Browse latest Browse all 44542

Customer #428370 on BOB-10859 - L6470 Stepper Driver Breakout

$
0
0

Hello. While I don’t have this board yet (or any dSPIN to play with at all) I can tell you that your problem is a platform problem. Note that the C standard does not offer any guarantees as to the number of bits of each type. In fact, even the “byte” that we take for granted today, used to be anywhere from 5 to 12 bits!! While I don’t think you’ll run into that anymore, you have to throw out your assumptions about data size of C types and determine what your compiler is specifically doing for each C type on a specific platform. Otherwise, best case, you’re code will not work and you’ll be frustrated in trying to solve it and in the worst case, you’re code will work fine until one day when you do something over that bit threshold, when your robot arm slaps you in the head. (OK, so that was probably a very weak attempt at a “cautionary tale” :)

So I suggest that you consider type-sniffed types from the posix library (i.e., your libc) implementation instead of the standard types “long”, “int”, etc.

EDIT: it’s not letting me use angle brackets in the code example :( but the stdint.h, should be <stdint.h>

#include stdint.h

int main(void) {
    int8_t   myint8;
    int16_t  myint16;
    int32_t  myint32;
    uint8_t  myuint8;
    uint16_t myuint16;
    uint32_t myuint32;
}

See also: <stdint.h>


Viewing all articles
Browse latest Browse all 44542

Trending Articles