I am attempting to generate, at compile time, an array of sine values. Here is my code;
#include <stdint.h> #include <stdbool.h> #include "driverlib/sysctl.h" #include "IQmath/IQmathLib.h" #define PI 3.14156 int32_t out_array[64]; uint8_t i; void main(void) { SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); //40 MHz for (i = 0; i<64; i++) { (_iq28) out_array[i] = _IQ28sin(i/64 * 2 * PI); } while(1) { } }
If I declare out_array[64] as type _IQ28, this will compile. but i do not observe any resulting values in memory. Is this fixable?
To fix the invisible memory problem I am attempting to type cast out_array[64], which is now declared as type int32_t, as type _IQ28. I get a compile error "#138 expression must be a modifiable Ivalue". So now I have a second question: how can I cast an _IQ28 value as type int32_t?
I am running CCS 6.01, compiling for the EK-TM4C123GXL launchpad.