CH559 GPIO最高切换频率


1. GPIO最高支持的切换频率是多少?


2. UART0中断使能会影响GPIO切换频率

相同的代码,一旦打开UART0的中断使能(ES = 1),GPIO的切换速率就会降低到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中断就会导致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电平




热门产品推荐 : 无线充电管理芯片CH246

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. 


SETB c 和 CLR c指令是单周期的,但是针对bit是双周期的


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.


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 什么时候WCH这么大方了,德国的仁兄还是多尝试下阿里巴巴海外版吧。

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