mirror of
https://github.com/rvtr/ctr_mcu.git
synced 2025-10-31 13:51:10 -04:00
電池温度監視修正(未完)
動作中にPMICが異常検出でOFF/デバッガがリセットかけた の判定修正 git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@18 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
parent
8bcafd8793
commit
be17613348
@ -188,7 +188,7 @@ __interrupt void int_adc( )
|
||||
|
||||
case ( ADC_SEL_BATT_TEMP ):
|
||||
hist_bt_temp[index] = ADCRH;
|
||||
raw_adc_temperature = getmean3( hist_tune );
|
||||
raw_adc_temperature = getmean3( hist_bt_temp );
|
||||
renge_task_immed_add( PM_bt_temp_update );
|
||||
break;
|
||||
|
||||
@ -199,14 +199,17 @@ __interrupt void int_adc( )
|
||||
|
||||
|
||||
// もっとまともな書き方がありそうだ
|
||||
// if( ADS == ADC_SEL_BATT_DET ){
|
||||
// if( ADS == ADC_SEL_BATT_DET ){b
|
||||
if( ADS != ADC_SEL_BATT_TEMP )
|
||||
{ // 電池判別は電源投入の一回のみ
|
||||
ADS += 1; // 次のチャンネル
|
||||
BT_TEMP_P = 1; // 電池温度監視スタート
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ADCEN = 0; // 止めてしまう
|
||||
BT_TEMP_P = 0; // 電池温度監視スタート
|
||||
adc_updated = 1;
|
||||
index = ( index == 2 ) ? 0 : ( index + 1 );
|
||||
}
|
||||
|
||||
12
trunk/main.c
12
trunk/main.c
@ -4,14 +4,7 @@
|
||||
開発技術部 藤田
|
||||
======================================================== */
|
||||
|
||||
/*
|
||||
管理担当がついてない
|
||||
pm_irq
|
||||
slp
|
||||
wl_rx
|
||||
wl_tx
|
||||
dbg
|
||||
*/
|
||||
|
||||
// ========================================================
|
||||
#include "incs.h"
|
||||
|
||||
@ -21,7 +14,6 @@
|
||||
#include "accero.h"
|
||||
#include "led.h"
|
||||
|
||||
|
||||
// ========================================================
|
||||
static void read_dipsw( );
|
||||
|
||||
@ -33,6 +25,8 @@ system_status_ system_status;
|
||||
|
||||
extern u8 boot_ura;
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
本当のエントリ関数は loader.c にあります
|
||||
======================================================== */
|
||||
|
||||
28
trunk/pm.c
28
trunk/pm.c
@ -196,27 +196,27 @@ void PM_init( )
|
||||
raw_adc_temperatureに入っている値を℃に変換するとともに、
|
||||
・レジスタにセット
|
||||
・残量ICにセット
|
||||
todo
|
||||
======================================================== */
|
||||
task_status_immed PM_bt_temp_update( )
|
||||
{
|
||||
u16 newrcomp;
|
||||
s8 newrcomp;
|
||||
static u8 temp_old = 0;
|
||||
static u8 count = 0; // たまにしか書きに行かない
|
||||
|
||||
volatile static u8 skip = 1;
|
||||
|
||||
if( skip != 0 ){
|
||||
return ( ERR_SUCCESS );
|
||||
}
|
||||
|
||||
/*
|
||||
サーミスタ - 10kΩ分圧点の時、
|
||||
常用温度では分圧比のカーブがほぼリニアで、
|
||||
村田 T[℃] = 81.48 - 111.97 x ratio
|
||||
TDK T = 81.406 - 111.81 x ratio
|
||||
*/
|
||||
vreg_ctr[VREG_C_BT_TEMP] =
|
||||
( u8 ) ( ( s16 ) ( ( 163 - ( 224 * raw_adc_temperature ) ) / 2 ) >> 8 );
|
||||
volatile u16 t1 = 63 * 256;
|
||||
volatile u16 t2 = 224 * raw_adc_temperature;
|
||||
volatile s16 t3 = ( t1 - t2 ) / 2;
|
||||
|
||||
vreg_ctr[VREG_C_BT_TEMP] = ((
|
||||
( s16 )( ( u16 )( 163 * 256 ) - ( u16 )( 224 * raw_adc_temperature ) ) / 2 )
|
||||
/ 256 );
|
||||
|
||||
// 時々/大きく変化があったら書きにゆく
|
||||
if( ( abs( vreg_ctr[VREG_C_BT_TEMP] - temp_old ) > 3 ) || ( count == 0 ) )
|
||||
@ -230,15 +230,7 @@ task_status_immed PM_bt_temp_update( )
|
||||
newrcomp = -( ( ( s16 ) vreg_ctr[VREG_C_BT_TEMP] - 20 ) * temp_co_dn );
|
||||
}
|
||||
newrcomp += rcomp;
|
||||
/*
|
||||
If Temperature > 20 Then
|
||||
NewRCOMP = StartingRCOMP + ((Temperature - 20) * TempCoUp)
|
||||
ElseIf Temp < 20 Then
|
||||
NewRCOMP = StartingRCOMP + ((Temperature - 20) * TempCoDown)
|
||||
Else
|
||||
NewRCOMP = StartingRCOMP
|
||||
End If
|
||||
*/
|
||||
|
||||
if( iic_mcu_write
|
||||
( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_RCOMP, 2, &newrcomp ) == ERR_SUCCESS )
|
||||
{
|
||||
|
||||
@ -12,10 +12,18 @@
|
||||
#include "pm.h"
|
||||
#include "rtc.h"
|
||||
|
||||
|
||||
//=========================================================
|
||||
u8 SW_pow_count, SW_home_count, SW_wifi_count;
|
||||
bit SW_pow_mask, SW_home_mask, SW_wifi_mask;
|
||||
|
||||
|
||||
|
||||
//=========================================================
|
||||
static void chk_emergencyExit();
|
||||
|
||||
|
||||
|
||||
/* ========================================================
|
||||
マイコン内部で必要なもの
|
||||
・省電力に入れる
|
||||
@ -25,6 +33,8 @@ bit SW_pow_mask, SW_home_mask, SW_wifi_mask;
|
||||
void tsk_sys( )
|
||||
{
|
||||
static u8 timeout = 0;
|
||||
|
||||
|
||||
RTCIMK = 0; // インターバル割り込み許可
|
||||
|
||||
switch ( system_status.pwr_state )
|
||||
@ -153,33 +163,15 @@ void tsk_sys( )
|
||||
break;
|
||||
|
||||
case ON: //---------------------------------------------
|
||||
{
|
||||
// PMICによる強制電源断チェック
|
||||
static u16 count;
|
||||
if( !RESET1_n )
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
// PMICによる強制電源断チェック
|
||||
// デバッガがreset1をアサートすることもある。そのときは全部リセット
|
||||
chk_emergencyExit();
|
||||
|
||||
if( count > 65530 ){
|
||||
/// コマンドで、正規にリセットをかけたときには、
|
||||
/// このチェックに引っかからないので大丈夫
|
||||
system_status.pwr_state = OFF_TRIG;
|
||||
renge_task_interval_run_force = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// SLP監視
|
||||
if( SLP_REQ ){
|
||||
system_status.pwr_state = SLEEP_TRIG;
|
||||
renge_task_interval_run_force = 1;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case SLEEP_TRIG: //-------------------------------------
|
||||
@ -190,23 +182,7 @@ void tsk_sys( )
|
||||
break;
|
||||
|
||||
case SLEEP: //------------------------------------------
|
||||
{
|
||||
static u16 count;
|
||||
|
||||
if( !RESET1_n )
|
||||
{
|
||||
count += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if( count > 65530 ){
|
||||
system_status.pwr_state = OFF_TRIG;
|
||||
renge_task_interval_run_force = 1;
|
||||
}
|
||||
}
|
||||
chk_emergencyExit();
|
||||
// スリープから復帰
|
||||
if( !SLP_REQ ){
|
||||
#ifdef _MODEL_CTR_
|
||||
@ -329,6 +305,8 @@ void tsk_sys( )
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
void tsk_sw( )
|
||||
{
|
||||
static u8 cnt_force_off = 0;
|
||||
@ -428,3 +406,25 @@ void tsk_sw( )
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************//**
|
||||
PMICが電源異常で止めたか確認
|
||||
**********************************************************/
|
||||
static void chk_emergencyExit(){
|
||||
if( !RESET1_n )
|
||||
{
|
||||
if( PM_chk_LDSW( ) == 0 )
|
||||
{
|
||||
// PMICが異常終了判断をした
|
||||
system_status.pwr_state = OFF_TRIG;
|
||||
renge_task_interval_run_force = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// デバッガなりがリセットをかけた
|
||||
vreg_ctr[VREG_C_COMMAND0] |= REG_BIT_RESET1_REQ;
|
||||
renge_task_immed_add( do_command0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,6 @@
|
||||
C:\WINDOWS\system32\cmd.exe /c echo touch magic.c
|
||||
touch magic.c
|
||||
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -qcvjl1wt -sainter_asm -zp -no led.c
|
||||
led.c(422) : CC78K0R warning W0401: Conversion may lose significant digits
|
||||
Compilation complete, 0 error(s) and 1 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -c9F0104 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\led.asm
|
||||
Assembly complete, 0 error(s) and 0 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\lk78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -obsr.lmf "..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r\s0rm.rel" -go85h,0FC00h,1024 -gi0FFFFFFFFFFFFFFFFFFFFh -pbsr_k0r.map -nkd -kp -gb7EFBFFh -b"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib" -bcl0rdm.lib -bcl0rm.lib -bcl0rmf.lib -i"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r" -dbsr_mcu.dr -s -w0 loader.rel pm.rel i2c_ctr.rel main.rel magic.rel WDT.rel i2c_mcu.rel i2c_twl.rel ini_VECT.rel led.rel rtc.rel vreg_ctr.rel vreg_twl.rel tasks.rel adc.rel renge.rel tasks_sys.rel accero.rel self_flash.rel reboot.rel
|
||||
Link complete, 0 error(s) and 0 warning(s) found.
|
||||
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\oc78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -o.\bsr.hex -nu -ki bsr.lmf
|
||||
Object Conversion Complete, 0 error(s) and 0 warning(s) found.
|
||||
C:\WINDOWS\system32\cmd.exe /c ruby C:\Cygwin\home\fujita_ryohei\ctr\nec_s_2_bsrbin.rb bsr.hex
|
||||
C:/Cygwin/home/fujita_ryohei/ctr/nec_s_2_bsrbin.rb:2: warning: variable $KCODE is no longer effective; ignored
|
||||
|
||||
Build Total error(s) : 0 Total warning(s) : 1
|
||||
Build Total error(s) : 0 Total warning(s) : 0
|
||||
|
||||
@ -45,15 +45,6 @@ Erase=OFF
|
||||
HighSpeed=OFF
|
||||
Symbol Reset=ON
|
||||
CPU Reset=ON
|
||||
File1=bsr.lmf
|
||||
LoadFilter1=5
|
||||
Offset1=0
|
||||
Object1=ON
|
||||
Symbol1=ON
|
||||
Erase1=ON
|
||||
HighSpeed1=OFF
|
||||
CPU Reset1=ON
|
||||
Symbol Reset1=ON
|
||||
[View File]
|
||||
Dir=.
|
||||
Filter=Source
|
||||
@ -78,10 +69,10 @@ Symbol Type=OFF
|
||||
Language=C
|
||||
Kanji=SJIS
|
||||
[Source]
|
||||
Geometry=36, 41, 1090, 857
|
||||
Window=Normal
|
||||
DispStart=288
|
||||
CaretPos=289,0
|
||||
Geometry=64, 33, 1090, 857
|
||||
Window=Hide
|
||||
DispStart=1
|
||||
CaretPos=0,0
|
||||
Mode=Normal
|
||||
DispFile=
|
||||
Address1=
|
||||
@ -140,10 +131,10 @@ SaveStart=
|
||||
SaveEnd=
|
||||
Accumulative=ON
|
||||
[Assemble]
|
||||
Geometry=118, 76, 600, 937
|
||||
Geometry=118, 275, 600, 738
|
||||
Window=Normal
|
||||
DispStart=14886
|
||||
CaretPos=14886,27
|
||||
DispStart=8803
|
||||
CaretPos=8803,27
|
||||
Address1=
|
||||
Address2=
|
||||
Address3=
|
||||
@ -186,11 +177,11 @@ SaveStart=
|
||||
SaveEnd=
|
||||
[Memory]
|
||||
Geometry=1046, 57, 584, 926
|
||||
Window=Normal
|
||||
Boundary=163
|
||||
Window=Hide
|
||||
Boundary=0
|
||||
Format=Hex
|
||||
Mode=Byte
|
||||
Endian=Little
|
||||
Endian=
|
||||
Ascii=OFF
|
||||
Idtag=OFF
|
||||
Address=
|
||||
@ -957,64 +948,74 @@ Detail=OFF
|
||||
Last Name=
|
||||
Count=0
|
||||
[Variable]
|
||||
Geometry=1138, 6, 440, 300
|
||||
Geometry=1138, 6, 440, 688
|
||||
Window=Normal
|
||||
Boundary=13762700
|
||||
0=.PIF21,P,S,A,+,1
|
||||
1=.PMK21,P,S,A,+,1
|
||||
2=.system_status.pwr_state,P,N,A,+,1
|
||||
3=.P12.0,P,S,A,+,1
|
||||
4=.system_status,.,N,A,+,1
|
||||
5=.vreg_twl,P,N,A,+,1
|
||||
6=.wifi_TX,P,N,A,+,1
|
||||
7=.temp,P,N,A,+,1
|
||||
Line=8
|
||||
0=.t1,P,N,A,+,1
|
||||
1=.t2,P,N,A,+,1
|
||||
2=.t3,D,N,A,+,1
|
||||
3=.hist_bt_temp,D,N,A,+,1
|
||||
4=.ADCRH,P,S,A,+,1
|
||||
5=.raw_adc_temperature,H,N,A,+,1
|
||||
6=.vreg_ctr,P,N,A,+,1
|
||||
7=.vreg_ctr[11],D,N,A,+,1
|
||||
8=.skip,P,N,A,+,1
|
||||
9=.system_status.pwr_state,P,N,A,+,1
|
||||
Line=10
|
||||
[Quick Watch]
|
||||
0=temp,P,A,1
|
||||
1=wifi_TX,P,A,1
|
||||
2=P20,P,A,1
|
||||
3=P2,B,A,1
|
||||
4=PM2,B,A,1
|
||||
5=PM20,B,A,1
|
||||
6=RTCEN,P,A,1
|
||||
7=system_status,P,A,1
|
||||
8=P12.0,P,A,1
|
||||
9=system_status.pwr_state,P,A,1
|
||||
10=pm12,P,A,1
|
||||
11=vreg_twl,P,A,1
|
||||
12=PMK21,P,A,1
|
||||
13=IFP21,P,A,1
|
||||
14=PIF21,P,A,1
|
||||
15=
|
||||
0=system_status.pwr_state,P,A,1
|
||||
1=pm12,P,A,1
|
||||
2=vreg_twl,P,A,1
|
||||
3=PMK21,P,A,1
|
||||
4=IFP21,P,A,1
|
||||
5=PIF21,P,A,1
|
||||
6=skip,P,A,1
|
||||
7=vreg_ctr[11],P,A,1
|
||||
8=raw_adc_temperature,P,A,1
|
||||
9=ADCRH,P,A,1
|
||||
10=hist_tune,P,A,1
|
||||
11=hist_bt_temp,P,A,1
|
||||
12=vreg_ctr,P,A,1
|
||||
13=t1,P,A,1
|
||||
14=t2,P,A,1
|
||||
15=t3,P,A,1
|
||||
[Software Break]
|
||||
Geometry=51, 459, 500, 200
|
||||
Window=Normal
|
||||
Width=150 30 200 100
|
||||
Name0=Swb00001
|
||||
Address0=self_flash.c#_firm_update+0x209
|
||||
Address0=0x46D
|
||||
Window0=ASM
|
||||
Status0=ON
|
||||
Name1=Swb00004
|
||||
Address1=vreg_twl.c#_vreg_twl_read+0x56
|
||||
Address1=0x3288
|
||||
Window1=ASM
|
||||
Status1=ON
|
||||
Name2=Swb00002
|
||||
Address2=vreg_twl.c#_vreg_twl_read+0x18
|
||||
Address2=0x324A
|
||||
Window2=ASM
|
||||
Status2=ON
|
||||
Name3=Swb00005
|
||||
Address3=tasks_sys.c#_tsk_sys+0x13a
|
||||
Name3=Swb00003
|
||||
Address3=0x3516
|
||||
Window3=ASM
|
||||
Status3=ON
|
||||
Name4=Swb00003
|
||||
Address4=tasks.c#_do_command0+0x8
|
||||
Name4=Swb00005
|
||||
Address4=0x3B7D
|
||||
Window4=ASM
|
||||
Status4=ON
|
||||
Name5=Swb00006
|
||||
Address5=led.c#_tsk_led_wifi+0x0
|
||||
Address5=0x3B84
|
||||
Window5=ASM
|
||||
Status5=ON
|
||||
Count=6
|
||||
Name6=Swb00008
|
||||
Address6=0x2270
|
||||
Window6=ASM
|
||||
Status6=ON
|
||||
Name7=Swb00007
|
||||
Address7=0x2263
|
||||
Window7=ASM
|
||||
Status7=ON
|
||||
Count=8
|
||||
[Reset]
|
||||
Debugger=ON
|
||||
Symbol=OFF
|
||||
|
||||
Loading…
Reference in New Issue
Block a user