SAR and Battery monitoring.

Writing software that controls the system and peripherals such as displays, SD cards, Buttons, LEDs, Serial Ports etc.
jedm@vpitech.com
Senior User
Posts: 32
Joined: Wed 2016-11-02 22:50

SAR and Battery monitoring.

Postby jedm@vpitech.com » Mon 2017-01-30 16:58

I'm trying to monitor battery level using the SAR and VHMON but am running into problems as this is a low level task running infrequently. I'm using the code in RdsRadio/fm_init.c as a model - possibly dangerous since it's commented out but the only one I could find. The attached code works most of the time but if interrupted, dies horribly.
xxx.c
(1.78 KiB) Downloaded 10 times


Is there a better example of battery monitoring or using the ADC?

User avatar
Henrik
VLSI Staff
Posts: 1007
Joined: Tue 2010-06-22 14:10

Re: SAR and Battery monitoring.

Postby Henrik » Wed 2017-03-15 14:10

Hello!

Is this in a system that uses the Touch LCD or on a text-based system?

If the Touch LCD driver TOUCH288.DL3 is in use, there's your problem: the driver uses the SAR hardware to read the touchpad. And your code snippet as it is misses on reserving the hardware for your use. To correct this issue:

Code: Select all

u_int16 VoltageTest(void) {
  /* Reserve the SAR hardware for your use. The touch driver will respect this. */
  ObtainHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_SAR);

  /* All your SAR manipulation code comes here. */

  /* Release the SAR hardware. */
  ReleaseHwLocksBIP(HLB_NONE, HLIO_NONE, HLP_SAR);
}


Does this help you?

Kind regards,
- Henrik
Good signatures never die. They just fade away.

jedm@vpitech.com
Senior User
Posts: 32
Joined: Wed 2016-11-02 22:50

Re: SAR and Battery monitoring.

Postby jedm@vpitech.com » Wed 2017-03-15 15:54

It's text based (actually just push buttons in the real world with a LED or two). I'll try the hardware locks, I've been trying to write up how to use them for the next person in line.

User avatar
Henrik
VLSI Staff
Posts: 1007
Joined: Tue 2010-06-22 14:10

Re: SAR and Battery monitoring.

Postby Henrik » Thu 2017-03-16 12:06

Hello!

If your system is text-based then I don't know what tomfoolery goes on behind your back. Anyway, check that the TOUCH288 driver isn't started in your config.txt.

If you still can't get sensible values, you could try the Forbid() / Permit() method of stopping multitasking for the time of your measurement even though comments seem to suggest that it won't necessarily help.

And if everything fails, let me know, and we'll think of something else.

Kind regards,
- Henrik
Good signatures never die. They just fade away.


Return to “System Software”

Who is online

Users browsing this forum: No registered users