AnalogIn is left justified though. Well unless the settings you changed, changed that too.
Your printf format specifier is invalid. What happens if you just use AnalogIn, no aditional calibration, and then preferably use %f in your printf statement and use the read command. That should just give back the AnalogIn value as a fraction of the supply voltage. Or if you want to use read_u16, use just %d as format specifier.
The tl;dr is that it should work fine without the calibration. And since it is just a heartbeat sensor it won't matter if you got an offset of a few LSB.
Hi,
I'm new to ARM, but have spent lots of time with PIC and Arduino/ATmega. Working with the FRDM board, and it's pretty sweet. Been having issues with the analog reading part. First attempt was filled with noise. Seems the Analog block needs to be calibrated on startup/reset. Calibration process provides gain settings, but offset is handled in software. my signal should idle and fluctuate around V/2, but my 10bit ADC is returning idle values around 800! I'm trying to load a value into the PG register, but it doesn't seem to stick. Still abit new to C/C++. Can someone see what I'm doing wrong?
I put the analog portion of mbed official freescale core into a .h file. Here's the code https://mbed.org/users/biomurph/code/AnalogIn_frdm/