Part Number: TMS320F28379D
Other Parts Discussed in Thread: LAUNCHXL-F28379D,
Tool/software: TI C/C++ Compiler
Hello,
I'm trying to use the LVGL graphics library on a Delfnio LAUNCHXL-F28379D (TMS320F28379D). I've spent some time testing various functions of the library on the board and noticed some unexpected results (compared to known-working output). I also saw in the compiler manual the note about "keeping expressions simple", though it's not entirely clear how this is always "possible". I'm looking for help re-writing some macros / functions so they are compatible with the hardware/toolchain.
For example:
#define LV_MATH_UDIV255(x) ((uint32_t)((uint32_t) (x) * 0x8081) >> 0x17)
This results in incorrect results at runtime.
Similarly, the following fails for almost every case:
long long _lv_pow(long long base, int8_t exp)
{
long long result = 1;
while(exp) {
if(exp & 1)
result *= base;
exp >>= 1;
base *= base;
}
return result;
}
I noticed there are hardware intrinsics in the compiler manual that are sure to come in handy. Many of them appear to specify a "return type", though that doesn't seem to be how it behaves are runtime. For example, I'd expect the following to be equivalent to the udiv255 macro shown above, but it results in a sign flip and wrong results.
#define LV_MATH_UDIV255(x) (uint32_t)( (uint32_t)__mpy((uint32_t)x, (uint32_t)0x8081) >> (uint32_t)23)
I apologize if much of this is 101 embedded stuff - I'm still learning embedded and (relearning) C. Thank you in advance for any help.
Cheers,
Kyle