CH551G的定時(shí)器2映射引腳T2_時(shí)鐘輸出異常(關(guān)聯(lián)CH552、CH554)

設(shè)置為T2_輸出時(shí)鐘后,在P1_4上測(cè)得如下非時(shí)鐘形狀的周期性波形

1720779616201975.png

1720779616152298.png

????#include?"compiler.h"
????#include?"CH552_SDCC.H"

void?CH551G_T2OUT_TEST?(?void?)?{

????P1_MOD_OC??=?0x00??????;
????P1_DIR_PU??=?0xFF??????;
????P3_MOD_OC??=?0x00??????;
????P3_DIR_PU??=?0xFF??????;

????P1?????????=?0x00??????;
????P3?????????=?0x00??????;

????T2MOD?????|=?bTMR_CLK??;
????T2MOD?????|=?bT2_CLK???;
????RCLK???????=?0?????????;
????TCLK???????=?0?????????;
????C_T2???????=?0?????????;
????CP_RL2?????=?0?????????;
????RCAP2??????=?0x00FF????;
????T2COUNT????=?0x00FF????;

????PIN_FUNC??|=?bT2_PIN_X?;
????TR2????????=?1?????????;
????T2MOD?????|=?T2OE??????;
}


您好。

測(cè)試下來(lái)是正常的哦??梢员O(jiān)察下是否有硬件引入該波形的可能性,以及程序中是否還初始化了和該引腳相關(guān)的ADC之類的功能。

fcad0a7309de25e2a93739364504360.jpg

image.png


我這個(gè)是CH551G,即使假設(shè)這是個(gè)沒(méi)有“簡(jiǎn)化”的CH552,添加了強(qiáng)制關(guān)閉ADC的代碼,P1_4的輸出依然是如頂樓示波器截圖所示。

	#include?"compiler.h"
	#include?"CH552_SDCC.H"

void?CH551G_T2OUT_TEST?(?void?)?{

	P1_MOD_OC??=???0x00??????;
	P1_DIR_PU??=???0xFF??????;
	P3_MOD_OC??=???0x00??????;
	P3_DIR_PU??=???0xFF??????;

	P1?????????=???0x00??????;
	P3?????????=???0x00??????;

	ADC_CTRL???=???0x00??????;
	ADC_CFG????=???0x00??????;

	T2MOD?????|=???bTMR_CLK??;
	T2MOD?????|=???bT2_CLK???;
	C_T2???????=???0?????????;
	RCLK???????=???0?????????;
	TCLK???????=???0?????????;
	CP_RL2?????=???0?????????;
	RCAP2??????=???0xAAAA????;
	T2COUNT????=???0xAAAA????;

	PIN_FUNC??|=???bT2_PIN_X?;
	T2MOD?????|=???T2OE??????;

	TR2????????=???1?????????;
}

這是SDCC輸出的匯編:

_CH551G_T2OUT_TEST:
	ar7?=?0x07
	ar6?=?0x06
	ar5?=?0x05
	ar4?=?0x04
	ar3?=?0x03
	ar2?=?0x02
	ar1?=?0x01
	ar0?=?0x00
;	src\CH551G_T2_Test.c:9:?P1_MOD_OC??=???0x00??????;
	mov	_P1_MOD_OC,#0x00
;	src\CH551G_T2_Test.c:10:?P1_DIR_PU??=???0xFF??????;
	mov	_P1_DIR_PU,#0xff
;	src\CH551G_T2_Test.c:11:?P3_MOD_OC??=???0x00??????;
	mov	_P3_MOD_OC,#0x00
;	src\CH551G_T2_Test.c:12:?P3_DIR_PU??=???0xFF??????;
	mov	_P3_DIR_PU,#0xff
;	src\CH551G_T2_Test.c:14:?P1?????????=???0x00??????;
	mov	_P1,#0x00
;	src\CH551G_T2_Test.c:15:?P3?????????=???0x00??????;
	mov	_P3,#0x00
;	src\CH551G_T2_Test.c:17:?ADC_CTRL???=???0x00??????;
	mov	_ADC_CTRL,#0x00
;	src\CH551G_T2_Test.c:18:?ADC_CFG????=???0x00??????;
	mov	_ADC_CFG,#0x00
;	src\CH551G_T2_Test.c:20:?T2MOD?????|=???bTMR_CLK??;
	orl	_T2MOD,#0x80
;	src\CH551G_T2_Test.c:21:?T2MOD?????|=???bT2_CLK???;
	orl	_T2MOD,#0x40
;	src\CH551G_T2_Test.c:22:?C_T2???????=???0?????????;
;	assignBit
	clr	_C_T2
;	src\CH551G_T2_Test.c:23:?RCLK???????=???0?????????;
;	assignBit
	clr	_RCLK
;	src\CH551G_T2_Test.c:24:?TCLK???????=???0?????????;
;	assignBit
	clr	_TCLK
;	src\CH551G_T2_Test.c:25:?CP_RL2?????=???0?????????;
;	assignBit
	clr	_CP_RL2
;	src\CH551G_T2_Test.c:26:?RCAP2??????=???0xAAAA????;
	mov	((_RCAP2?>>?0)?&?0xFF),#0xaa
	mov	((_RCAP2?>>?8)?&?0xFF),#0xaa
;	src\CH551G_T2_Test.c:27:?T2COUNT????=???0xAAAA????;
	mov	((_T2COUNT?>>?0)?&?0xFF),#0xaa
	mov	((_T2COUNT?>>?8)?&?0xFF),#0xaa
;	src\CH551G_T2_Test.c:29:?PIN_FUNC??|=???bT2_PIN_X?;
	orl	_PIN_FUNC,#0x01
;	src\CH551G_T2_Test.c:30:?T2MOD?????|=???T2OE??????;
	orl	_T2MOD,#0x02
;	src\CH551G_T2_Test.c:32:?TR2????????=???1?????????;
;	assignBit
	setb	_TR2
;	src\CH551G_T2_Test.c:33:?}
	ret



看到最后的ret反應(yīng)過(guò)來(lái)了,我最后沒(méi)加while ( 1 ) ;

抱歉給您添麻煩了。


只有登錄才能回復(fù),可以選擇微信賬號(hào)登錄

国产91精品新入口,国产成人综合网在线播放,九热这里只有精品,本道在线观看,美女视频a美女视频,韩国美女激情视频,日本美女pvp视频