PMIC MC34708 battery monitor with mc34708 adc

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

PMIC MC34708 battery monitor with mc34708 adc

ソリューションへジャンプ
6,328件の閲覧回数
VishnuSankar
Contributor I

I am using iMX53 QSB based design. I am using Android gingerbread and using linux 2.6.35.

we are using MC34708 pmic for both touch screen as well as battery monitoring (not for charging). battery monitoring

will work if we are not touching the screen. if we touched battery, monitor will stop afterwards.


For making both active at the same time what should I do.

can anyone suggest some tips to solve this issue

ラベル(3)
0 件の賞賛
返信
1 解決策
5,623件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

     I borrowed a customermized board based on MAX1705B + MC34708 + I.MX536, 1/10 battery voltage is connected to ADC_IN9 on MC34708. I modified max17085_battery.c, commented corresponding code for DA9053, and added my codes; In mc34708_adc.c, I added codes for voltage sample at adc_in9. I have validated codes, battery voltage in android is OK.

    Please see attach ! they should be valueable for your project !

Regards,

Weidong

元の投稿で解決策を見る

0 件の賞賛
返信
21 返答(返信)
5,619件の閲覧回数
admin
Specialist II

From AnandBalakrishnan

Hi Vishnu,

Touchscreen uses same ADC block as used by the dedicated and general purpose ADC inputs. Results from touchscreen and battery monitor are stored in the same ADRESULTx registers. When touchscreen is enabled, it overrides other ADC functions. Hence, battery monitoring has to be enabled intermittently to check the status rather than being continuously on.

Regards,

Anand

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hi Anand,

Thank you for your Help.

So should I disable the Touch screen when I need ADC input?  But if I am Disabling the touch screen it will effect the complete setup.

can u help me to disable the touch screen when I need ADC input, with out affecting touch screen.

regards,

vishnu

0 件の賞賛
返信
5,619件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

     Please adjust 2 places , and try :

(1) kernel_imx/drivers/mxc/pmic/core/pmic_external.c

unsigned int pmic_get_active_events(unsigned int *active_events)

{

     .......

pmic_read(REG_INT_STATUS0, &status0);

msleep(10); //added by weidong

pmic_read(REG_INT_STATUS1, &status1);

msleep(10); //added by weidong

pmic_write(REG_INT_STATUS0, status0);

msleep(10); //added by weidong

pmic_write(REG_INT_STATUS1, status1);

status0 &= events_enabled0;

status1 &= events_enabled1;

.....

}

(2)kernel_imx/drivers/mxc/pmic/mc34708/mc34708_adc.c

#define MC34708_ADC_CH9       9

<Probably you don't need adjust here, I used ADC channel 9 to sample battery voltage>

PMIC_STATUS mc34708_pmic_adc_convert(t_channel channel, unsigned short *result)

{

     .......

if ((channel <= BATTERY_CURRENT)||(channel==MC34708_ADC_CH9)) {
  INIT_COMPLETION(adcdone_it);
  ret = pmic_write_reg(MC34708_REG_ADC2,BITFVAL(ADSEL0, BATTERY_VOLTAGE),BITFMASK(ADSEL0));
  if (PMIC_SUCCESS != ret)
   goto error1;

  ret = pmic_write_reg(MC34708_REG_ADC2,BITFVAL(ADSEL1, BATTERY_CURRENT),BITFMASK(ADSEL1));
  if (PMIC_SUCCESS != ret)
   goto error1;
  /*Using ADSEL2 field to Set No.9 Channel : added by weidong-2012-12-20*/
  ret = pmic_write_reg(MC34708_REG_ADC2,BITFVAL(ADSEL2, MC34708_ADC_CH9),BITFMASK(ADSEL2));
  if (PMIC_SUCCESS != ret)
   goto error1;
/*end of codes :2012-12-20*/
  ret = pmic_write_reg(MC34708_REG_ADC0, BITFVAL(ADEN, 1),BITFMASK(ADEN));

  if (PMIC_SUCCESS != ret)
   goto error1;

     ........
  ret = pmic_write_reg(MC34708_REG_ADC0,BITFVAL(ADSTOP, ADC_MAX_CHANNEL),BITFMASK(ADSTOP));

  ret = pmic_read_reg(MC34708_REG_ADC4, &register_val,PMIC_ALL_BITS);

/*Usging ADIN9 & result is in Register ADC5:added by weidong-2012-12-20*/
  ret = pmic_read_reg(MC34708_REG_ADC5, &adc5_reg_val,PMIC_ALL_BITS);
  if (PMIC_SUCCESS != ret)
   goto error1;
  /*end of codes :2012-12-20*/
  if (PMIC_SUCCESS != ret)
   goto error1;

     ........

  switch (channel) {

  case BATTERY_VOLTAGE:

   *result = BITFEXT(register_val, ADRESULT0);

   break;

  case BATTERY_CURRENT:

   *result = BITFEXT(register_val, ADRESULT1);

   break;

   /* Read the result of ADIN9 : added by weidong-2012-12-20*/

  case MC34708_ADC_CH9:

    *result = BITFEXT(adc5_reg_val, ADRESULT2);

   break;

   /*end of codes :2012-12-20*/

  default:

   *result = BITFEXT(register_val, ADRESULT0);

   break;

  }

     .......

}

Regards,

Weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hi Weidong Sun,


I can see that ripley_battery_get_property function is not being called by android after we press the touch screen.


what are the properties android will check.?



regards


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

hello,vishnu,

     There is charger module in mc34708, this function is mc34708_battery.c,  which is driver for mc34708 charger. in this driver ,battery voltage can be read from ADC0 channel. I think you don't use this driver, you should program a driver for the charger on your board. in charger's driver, providing interface for android power. you can refer to max17085_battery.c and program yours.

     In system, battery volgtage should be divided into lower one(such as below 2.5V) at first, then connected to ADC9 of mc34708.

Weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hi Weidong Sun,


     I am using This driver only mc34708_battery.c in that I have changed the ADRESULT register to 5th one. And I am getting the Printk message on my console that I have added in ripley_battery_get_property function. But those messages will stop just after I press the touch screen. So I dont think it is not using this driver, And one more thing, If I am doing "cat  /sys/class/battery* "  I am able to get the updated the results in console, but not on android battery monitor.



regards


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

     OK, then using this drvier , let us do a test !

     Open "~/myandroid/frameworks/base/services/jni/com_android_server_BatteryService.cpp", and find :

#define POWER_SUPPLY_PATH "/sys/class/power_supply"

change it to your battery path:

#define POWER_SUPPLY_PATH "/sys/class/battery"

     Then compile android file system, and try !

Regards,

Weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hi Weidong Sun,


          I tried it. But now the battery icon itself is showing a question mark.


regards,


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

      Question mark ? Paste it here , OK ?

weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


               Question Mark is showing inside the Battery insicator, something like battery not recognized,


thanks and regards,


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

      Is it a "?" in battery mark ?

      In addition, Could you share your shematic with me ?

weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


Yes it is the same.

Yeah I  will share the schematic of charger.

0 件の賞賛
返信
5,624件の閲覧回数
weidong_sun
NXP TechSupport
NXP TechSupport

Hello,vishnu,

     I borrowed a customermized board based on MAX1705B + MC34708 + I.MX536, 1/10 battery voltage is connected to ADC_IN9 on MC34708. I modified max17085_battery.c, commented corresponding code for DA9053, and added my codes; In mc34708_adc.c, I added codes for voltage sample at adc_in9. I have validated codes, battery voltage in android is OK.

    Please see attach ! they should be valueable for your project !

Regards,

Weidong

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


Thanks for your support.


I made changed the mc34708_battery.c driver code completely by making max_17085 as the reference, and I am using your mc34708_adc.c only, but after that I am not at all getting the battery indicator itself. that means there is no battery indicator at all.


can you tell me why is it happening,


I am attaching my driver code here.


regards,


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
williamxu
Contributor I

Hi weidong,

My imx53 SPI mc34708 still not work.

I try to make the Linux-2.6.35.3's ECSPI work,try to add the clock for it and try to make SPI MC34708 work.

I found it seems u-boot and uImage are mismatch that not init the customer BOARD.I never seen the register in my log file.

I attach my log file again to you.

Please give a help.

regards!

william

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


I think that is because of my calculation for capacity. I am using a 3.7v 4000mAh battery, and the fully charged battery will give 4.2V

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


Thanks for your support.


Now its working fine, I made a big mistake in battery capacity calculation now its working fine with my new driver based on MAX17085_battery.c driver.


Thanks once again for your support,



regards,


vishnu

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

Hello Weidong Sun,


I am facing an issue now, 

If a battery adc reading is happening at the same time of touch screen reading, then my other peripherals will stop working including charger adapter status, buttons(back, settings, home) , and even not getting the console, but touch screen and LCD are working fine.


Its happening only if both are happening at the same time. I am not able to trouble-shoot, because my console itself is not coming.


can you help me on this



regards,



VISHNU

0 件の賞賛
返信
5,619件の閲覧回数
VishnuSankar
Contributor I

I am also using ADC channel 9 only.

0 件の賞賛
返信
5,618件の閲覧回数
VishnuSankar
Contributor I

Hi Weidong Sun,

Thank you for your support. I have changed the code according to the patch you have provided, But still I am getting the same issue, When I am touching the Screen the battery monitoring stops.  I think my battery code is also giving issue.

I will attach the source code of both mc34708_adc.c and battery.c. sometimes my register implementation is also giving issues.

Kindly go through this

0 件の賞賛
返信