CH559 GPIO最高切換頻率

有兩個(gè)問題:

1. GPIO最高支持的切換頻率是多少?

目前測(cè)試看直接通過匯編的SETB和CLR調(diào)整GPIO腳(已配置成輸出)的電平,MCU工作在56MHz,從示波器觀察輸出大約是14MHz,從理論上講,SETB和CLR都是單指令周期,那么輸出頻率應(yīng)該在56/2=28MHz.


2. UART0中斷使能會(huì)影響GPIO切換頻率

相同的代碼,一旦打開UART0的中斷使能(ES = 1),GPIO的切換速率就會(huì)降低到330KHz左右。


void main()?

{

? CfgFsys();? ? ? ? ? ? ? ? ? ? // Init system clk

? mDelaymS(5);? ? ? ? ? ? ? ? ? // Wait the clk to be steady


? CH559UART0Alter();? ? ? ? ? ? // Switch UART0 pin to 37/38

? mInitSTDIO();? ? ? ? ? ? ? ? ? ? ? ? ?// Init UART0 for stdio

? //ES = 1;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Enalbe UART0 interrupt,一旦打開UART0中斷就會(huì)導(dǎo)致GPIO切換速度極度降低

? IE_UART1 = 1;

? EA = 1;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?// Enalbe interrupt for all


? CH559GPIOModeSelt(1, 6, 6); // 配置pin1輸出

? while(1) pwm_pin1(255);? ? ? ? // pwm_pin1中通過CLR/SETB切換管腳pin1電平

}


以上均是使用CH559EVT中的示例中的函數(shù)。目前驗(yàn)證看,UART0中斷使能會(huì)影響所有端口的切換速度,而不只是UART0映射到的端口0;UART1中斷使能沒有此問題。

麻煩盡快確認(rèn),是否為軟件配置問題,謝謝。

SETB and CLR are 2 Byte Instructions, therefore 2 cycles. Your observation of 14MHz matchs.?

With CPL you might reach 28MHz.

You dont show any interrupt handler for Uart0. I guess the irq fires again and again, possibly because TI does not get cleared. Therefore just one instruction gets executed between irqs.?


Hi usbman,


Many thanks to you.

I have checked the instruction datasheet named?CH55X匯編指令.PDF,? and you are right, that both SETB bit and CLR bit? would take two cycles, so the first question is cleared.

And again, you are right that TI flag needs to be cleared as well. Forgive my carelessness and put up such a junior issue to bother people.


BTW, it seems that you are not from China, but you are so familar with WCH series of MCUs. My hat off to you.?


?這兩個(gè)確實(shí)是雙周期指令。


SETB c 和 CLR c指令是單周期的,但是針對(duì)bit是雙周期的


@sunshine


You are right, I am from Germany though I had lived in China for some time.

Some WCH chips are available here too. Unfortunately the more interesting chips are out of stock even at LCSC these days. for exampe CH549 or the CH555.


ummm,我的意思就是SETB和CLR單個(gè)位就是雙周期的,正如你所說的,匯編指令的PDF里寫了。

and for @usbman,German friend,ask WCH for a few CH549 or CH555 less than 5chips may be a better choose,specially if you want to design something interesting with these.微信截圖_20211026215431.png


@home_everywhere 什么時(shí)候WCH這么大方了,德國(guó)的仁兄還是多嘗試下阿里巴巴海外版吧。

@usbman, maybe you can try Alibaba/Taobao to see if some vendors would like to ship these kinds of chips to Germany.


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

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