I2C_CTR.FREE をマイコンのデバッグに使っていた。

SoCで使うそうなので解放
I2C_CTRのウェイトコンディション解除のタイミングを修正
 次の準備ができてから解放する。本来はこうあるべき?戻すかもしれない

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@87 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2010-01-28 00:33:22 +00:00
parent 25206d2ee7
commit 91c33279a7
8 changed files with 86 additions and 102 deletions

View File

@ -8,7 +8,7 @@
#define MCU_VER_MAJOR 0x00 #define MCU_VER_MAJOR 0x00
#define MCU_VER_MINOR 0x0D #define MCU_VER_MINOR 0x0D
#define _OVERCLOCK_ //#define _OVERCLOCK_
// 古い(C)電源ボード // 古い(C)電源ボード
//#define _PM_BUG_ //#define _PM_BUG_

View File

@ -38,6 +38,7 @@
#define WTIM WTIM1 #define WTIM WTIM1
#define TRC TRC1 #define TRC TRC1
#define SMC SMC1 #define SMC SMC1
#define DFC DFC1
#endif #endif
@ -65,7 +66,9 @@ __interrupt void int_iic_ctr( )
static u8 state = IIC_IDLE; static u8 state = IIC_IDLE;
static u8 reg_adrs; static u8 reg_adrs;
static u8 reg_adrs_internal; static u8 reg_adrs_internal;
static u8 trx_buf; static u8 tx_buf;
u8 rx_buf;
u8 tx_buf_temp;
EI(); EI();
@ -125,16 +128,16 @@ __interrupt void int_iic_ctr( )
// 自局呼び出しに応答。 // 自局呼び出しに応答。
// 初期化など // 初期化など
SPIE = 1; SPIE = 1;
WREL = 1; // ウェイト解除
state = IIC_RCV_REG_ADRS; state = IIC_RCV_REG_ADRS;
WREL = 1; // ウェイト解除
break; break;
case ( IIC_RCV_REG_ADRS ): // 2バイト目(レジスタアドレス)受信後に来る case ( IIC_RCV_REG_ADRS ): // 2バイト目(レジスタアドレス)受信後に来る
// レジスタアドレス受信 // レジスタアドレス受信
reg_adrs = IICA; reg_adrs = IICA;
WREL = 1; tx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
trx_buf = vreg_ctr_read( reg_adrs ); // データの準備をしておく
state = IIC_TX_OR_RX; state = IIC_TX_OR_RX;
WREL = 1;
break; break;
case ( IIC_TX_OR_RX ): // ↑の次に来る割り込み。STなら送信準備、データが来たら書き込まれ case ( IIC_TX_OR_RX ): // ↑の次に来る割り込み。STなら送信準備、データが来たら書き込まれ
@ -165,13 +168,13 @@ __interrupt void int_iic_ctr( )
default: // バースト R/W でここが何回も呼ばれることになる default: // バースト R/W でここが何回も呼ばれることになる
if( state == IIC_TX ) if( state == IIC_TX )
{ // 送信 { // 送信
IICA = trx_buf; // IICA = tx_buf;
vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理 vreg_ctr_after_read( reg_adrs ); // 読んだらクリアなどの処理
} }
else else
{ // 受信 { // 受信
trx_buf = IICA; rx_buf = IICA;
vreg_ctr_write( reg_adrs, trx_buf ); vreg_ctr_write( reg_adrs, rx_buf );
WREL = 1; WREL = 1;
} }
if( reg_adrs != VREG_C_ACC_HOSU_HIST ) if( reg_adrs != VREG_C_ACC_HOSU_HIST )
@ -181,11 +184,12 @@ __interrupt void int_iic_ctr( )
if( state == IIC_TX ) if( state == IIC_TX )
{ // さらにつぎに送るデータの準備だけシテオク。SPが来て使われないかもしれない { // さらにつぎに送るデータの準備だけシテオク。SPが来て使われないかもしれない
trx_buf = vreg_ctr_read( reg_adrs ); tx_buf_temp = vreg_ctr_read( reg_adrs );
IICA = tx_buf;
tx_buf = tx_buf_temp;
} }
break; break;
} }
} }
@ -204,11 +208,7 @@ void IIC_ctr_Init( void )
IICAPR0 = 1; /* set INTIICA high priority */ IICAPR0 = 1; /* set INTIICA high priority */
IICAPR1 = 0; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */
#ifdef _MODEL_WM0_
P20 &= ~0x3; P20 &= ~0x3;
#else
P6 &= ~0x3;
#endif
SVA = IIC_C_SLAVEADDRESS; SVA = IIC_C_SLAVEADDRESS;
IICF = 0x01; IICF = 0x01;
@ -220,19 +220,17 @@ void IIC_ctr_Init( void )
WTIM = 1; // 自動でACKを返した後clkをLに固定する WTIM = 1; // 自動でACKを返した後clkをLに固定する
ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない
IICWH = 8; IICWH = 5;
IICWL = 10; // L期間の長さ IICWL = 10; // L期間の長さ
SMC = 1; // 高速モード SMC = 1; // 高速モード
DFC = 1; // デジタルフィルタon (@fast mode)
IICAMK = 0; // 割り込みを許可 IICAMK = 0; // 割り込みを許可
IICE = 1; IICE = 1;
#ifdef _MODEL_WM0_
PM20 &= ~0x3; /* set clock pin for IICA */ PM20 &= ~0x3; /* set clock pin for IICA */
#else
PM6 &= ~0x3; /* set clock pin for IICA */
#endif
} }

View File

@ -168,11 +168,7 @@ void IIC_twl_Init( void )
IICAPR0 = 0; /* set INTIICA high priority */ IICAPR0 = 0; /* set INTIICA high priority */
IICAPR1 = 0; /* set INTIICA high priority */ IICAPR1 = 0; /* set INTIICA high priority */
#ifdef _MODEL_WM0_
P6 &= ~0x3; P6 &= ~0x3;
#else
P20 &= ~0x3;
#endif
SVA = IIC_T_SLAVEADDRESS; SVA = IIC_T_SLAVEADDRESS;
IICF = 0x01; IICF = 0x01;
@ -184,7 +180,7 @@ void IIC_twl_Init( void )
WTIM = 1; // 自動でACKを返した後clkをLに固定する WTIM = 1; // 自動でACKを返した後clkをLに固定する
ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない ACKE = 1; // ダメCPUは無視して次の通信をはじめるかもしれないんで早くclkを開放しないといけない
IICWH = 8; IICWH = 5;
IICWL = 10; // L期間の長さ IICWL = 10; // L期間の長さ
SMC = 1; SMC = 1;
@ -192,11 +188,7 @@ void IIC_twl_Init( void )
IICAMK = 0; // 割り込みを許可 IICAMK = 0; // 割り込みを許可
IICE = 1; IICE = 1;
#ifdef _MODEL_WM0_
PM6 &= ~0x3; /* set clock pin for IICA */ PM6 &= ~0x3; /* set clock pin for IICA */
#else
PM20 &= ~0x3; /* set clock pin for IICA */
#endif
LREL = 1; LREL = 1;
} }

View File

@ -189,7 +189,6 @@ task_status_immed PM_bt_temp_update( )
DBG_P_n = 1; DBG_P_n = 1;
temperature = 81.45 - 111.9 * raw_adc_temperature/256.0; temperature = 81.45 - 111.9 * raw_adc_temperature/256.0;
vreg_ctr[VREG_C_BT_TEMP] = (u8)temperature; vreg_ctr[VREG_C_BT_TEMP] = (u8)temperature;
vreg_ctr[VREG_C_FREE0 ] = (u8)( temperature % 100 * 100 );
DBG_P_n = 0; DBG_P_n = 0;
} }
@ -707,7 +706,6 @@ void tsk_batt( )
PM_get_batt_left(); PM_get_batt_left();
// dubug monitor // dubug monitor
vreg_ctr[ VREG_C_FREE1 ] = iic_mcu_read_a_byte( IIC_SLA_BT_GAUGE, BT_GAUGE_REG_VCELL );
return; return;
} }

View File

@ -38,8 +38,6 @@ void tsk_debug2( )
{ {
u8 str[4]; u8 str[4];
return;
if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) ) if( ( system_status.pwr_state == ON ) || ( system_status.pwr_state == SLEEP ) )
{ {
/* /*
@ -48,10 +46,11 @@ void tsk_debug2( )
str[1] = vreg_ctr[ VREG_C_STATUS ]; str[1] = vreg_ctr[ VREG_C_STATUS ];
str[0] = vreg_ctr[ VREG_C_RTC_SEC ]; str[0] = vreg_ctr[ VREG_C_RTC_SEC ];
*/ */
str[3] = vreg_ctr[ VREG_C_BT_TEMP ]; str[3] = vreg_ctr[ VREG_C_DBG1 ];
str[2] = vreg_ctr[ VREG_C_FREE0 ]; str[2] = vreg_ctr[ VREG_C_DBG2 ];
str[1] = vreg_ctr[ VREG_C_FREE1 ]; str[1] = vreg_ctr[ VREG_C_DBG3 ];
str[0] = MIN; // str[1] = MIN;
str[0] = SEC;
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_IRQ1 ] ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_IRQ1 ] );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, boot_ura ); // iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, boot_ura );

View File

@ -80,8 +80,8 @@ Kanji=SJIS
[Source] [Source]
Geometry=173, 154, 1012, 920 Geometry=173, 154, 1012, 920
Window=Normal Window=Normal
DispStart=209 DispStart=274
CaretPos=210,0 CaretPos=275,0
Mode=Normal Mode=Normal
DispFile= DispFile=
Address1= Address1=
@ -142,8 +142,8 @@ Accumulative=ON
[Assemble] [Assemble]
Geometry=605, 2, 600, 400 Geometry=605, 2, 600, 400
Window=Normal Window=Normal
DispStart=14008 DispStart=16374
CaretPos=14008,27 CaretPos=16374,27
Address1= Address1=
Address2= Address2=
Address3= Address3=
@ -858,32 +858,33 @@ Count=0
Geometry=1225, 6, 354, 910 Geometry=1225, 6, 354, 910
Window=Normal Window=Normal
Boundary=13762700 Boundary=13762700
0=.new_task,.,N,A,+,1 0=.tx_buf,P,N,A,+,1
1=.if2h,P,S,A,+,1 1=.new_task,P,N,A,+,1
2=.pool,P,N,A,+,1 2=.if2h,P,S,A,+,1
3=.new_task,.,N,A,+,1 3=.pool,P,N,A,+,1
4=.vreg_ctr,P,N,A,+,1 4=.new_task,P,N,A,+,1
5=.cmd_BL,P,N,A,+,1 5=.vreg_ctr,P,N,A,+,1
6=.P7,B,S,A,+,1 6=.cmd_BL,P,N,A,+,1
7=.p5,B,S,A,+,1 7=.P7,B,S,A,+,1
Line=8 8=.p5,B,S,A,+,1
Line=9
[Quick Watch] [Quick Watch]
0=SEC,P,A,1 0=rtcif,P,A,1
1=rtcif,P,A,1 1=vreg_twl,P,A,1
2=vreg_twl,P,A,1 2=pm0,P,A,1
3=pm0,P,A,1 3=data,P,A,1
4=data,P,A,1 4=P5.3,P,A,1
5=P5.3,P,A,1 5=p4.3,P,A,1
6=p4.3,P,A,1 6=pu0,P,A,1
7=pu0,P,A,1 7=p5,B,A,1
8=p5,B,A,1 8=P7,B,A,1
9=P7,B,A,1 9=cmd_BL,P,A,1
10=cmd_BL,P,A,1 10=vreg_ctr,P,A,1
11=vreg_ctr,P,A,1 11=pool,P,A,1
12=pool,P,A,1 12=if2,P,A,1
13=if2,P,A,1 13=if2h,P,A,1
14=if2h,P,A,1 14=new_task,P,A,1
15=new_task,P,A,1 15=tx_buf,P,A,1
[Software Break] [Software Break]
Geometry=1204, 674, 500, 428 Geometry=1204, 674, 500, 428
Window=Normal Window=Normal
@ -904,15 +905,11 @@ Name3=Swb00006
Address3=self_flash.c#_firm_duplicate+0x0 Address3=self_flash.c#_firm_duplicate+0x0
Window3=ASM Window3=ASM
Status3=ON Status3=ON
Name4=Swb00010 Name4=Swb00003
Address4=renge.c#_renge_task_immed_run+0xe3 Address4=task_misc.c#_do_command0+0x10
Window4=ASM Window4=ASM
Status4=ON Status4=ON
Name5=Swb00003 Count=5
Address5=task_misc.c#_do_command0+0x10
Window5=ASM
Status5=ON
Count=6
[Reset] [Reset]
Debugger=ON Debugger=ON
Symbol=OFF Symbol=OFF

View File

@ -596,9 +596,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rml.rel Startup=s0rml.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VfiFileBoot0= VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0
@ -668,9 +668,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rll.rel Startup=s0rll.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VF78K0Rchk=0 VF78K0Rchk=0
VF78K0Rvs= VF78K0Rvs=
[Options.CC78K0R 2] [Options.CC78K0R 2]
@ -747,9 +747,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rm.rel Startup=s0rm.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VfiFileBoot0= VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0
@ -828,9 +828,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rml.rel Startup=s0rml.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VfiFileBoot0= VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0
@ -905,9 +905,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rml.rel Startup=s0rml.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VfiFileBoot0= VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0
@ -986,9 +986,9 @@ Floatingpoint=0
Muldivunit=1 Muldivunit=1
Mulunit=1 Mulunit=1
Startup=s0rml.rel Startup=s0rml.rel
Library1=cl0rdm.lib Library1=cl0rm.lib
Library2=cl0rm.lib Library2=cl0rmf.lib
Library3=cl0rmf.lib Library3=
VfiFileBoot0= VfiFileBoot0=
VfiFileBoot1=boot.vfi VfiFileBoot1=boot.vfi
VF78K0Rchk=0 VF78K0Rchk=0

View File

@ -11,14 +11,14 @@ T=4b445f00
7=rtc.h 7=rtc.h
8=reboot.h 8=reboot.h
[pm.c] [pm.c]
T=4b4d808f T=4b5d7b67
1=incs.h 1=incs.h
2=adc.h 2=adc.h
3=led.h 3=led.h
4=pm.h 4=pm.h
5=renge\renge.h 5=renge\renge.h
[i2c_ctr.c] [i2c_ctr.c]
T=4b57f645 T=4b5e46d7
1=incs.h 1=incs.h
2=accero.h 2=accero.h
[main.c] [main.c]
@ -31,7 +31,7 @@ T=4b57fe0b
6=led.h 6=led.h
7=adc.h 7=adc.h
[magic.c] [magic.c]
T=4b58003f T=4b5e3f7f
1=config.h 1=config.h
[WDT.c] [WDT.c]
T=4afd21ca T=4afd21ca
@ -41,7 +41,7 @@ T=4b0bae4b
1=incs.h 1=incs.h
2=i2c_mcu.h 2=i2c_mcu.h
[i2c_twl.c] [i2c_twl.c]
T=4b580039 T=4b5e46a6
1=incs.h 1=incs.h
2=i2c_twl_defs.h 2=i2c_twl_defs.h
[ini_VECT.c] [ini_VECT.c]
@ -55,7 +55,7 @@ T=4b4438bb
T=4b4438a1 T=4b4438a1
1=incs.h 1=incs.h
[vreg_ctr.c] [vreg_ctr.c]
T=4b57f3e1 T=4b5e46c1
1=incs.h 1=incs.h
2=vreg_ctr.h 2=vreg_ctr.h
3=rtc.h 3=rtc.h
@ -78,7 +78,7 @@ T=4b502014
3=pm.h 3=pm.h
4=led.h 4=led.h
[renge\renge.c] [renge\renge.c]
T=4b5802da T=4b5d73b9
1=renge\renge.h 1=renge\renge.h
2=renge\renge_task_intval.h 2=renge\renge_task_intval.h
3=renge\renge_task_immediate.h 3=renge\renge_task_immediate.h
@ -87,7 +87,7 @@ T=4b5802da
6=user_define.h 6=user_define.h
7=bsr_system.h 7=bsr_system.h
[accero.c] [accero.c]
T=4b57fc13 T=4b5d7f5b
1=incs.h 1=incs.h
2=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h 2=..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\inc78k0r\math.h
[self_flash.c] [self_flash.c]
@ -109,13 +109,13 @@ T=4b4d6c9b
6=pm.h 6=pm.h
7=rtc.h 7=rtc.h
[task_debug.c] [task_debug.c]
T=4b42e64f T=4b5d91b9
1=incs.h 1=incs.h
2=renge\renge.h 2=renge\renge.h
3=pm.h 3=pm.h
4=accero.h 4=accero.h
[task_misc.c] [task_misc.c]
T=4b42ee33 T=4b595e25
1=incs.h 1=incs.h
2=renge\renge.h 2=renge\renge.h
3=pm.h 3=pm.h
@ -147,7 +147,7 @@ T=4b023fdb
[user_define.h] [user_define.h]
T=4b442a95 T=4b442a95
[config.h] [config.h]
T=4b4fe6cf T=4b5e3100
[bsr_system.h] [bsr_system.h]
T=4b3064de T=4b3064de
[renge\renge.h] [renge\renge.h]