ch55xduino icon indicating copy to clipboard operation
ch55xduino copied to clipboard

Add 6MHz clock support

Open Saatvik-Aggarwal opened this issue 1 year ago • 3 comments

I've added support for 6MHz clock. I've tested it for accuracy with my CH552G.

Here is a loop function you can use to test:

void loop() {
  delay(1000);
  USBSerial_println(millis());
  
  delay(2000);
  USBSerial_println(millis());

  delay(4000);
  USBSerial_println(millis());

  delay(8000);
  USBSerial_println(millis());
  
  delay(16000);
  USBSerial_println(millis());
}

Saatvik-Aggarwal avatar Jun 05 '23 07:06 Saatvik-Aggarwal

Please do not include the formatting code into the PR or I can not see where you changed. At this moment you changed every line of the code.

Also please only cherry pick the necessary commits.

I know there are format issue in this repo and I'll get them fixed these days. You can do your part afterward.

DeqingSun avatar Jun 05 '23 14:06 DeqingSun

@DeqingSun I've undone the formatting changes. Let me know what you think. I had to add a "hacky" part for the delay() function, I'm not sure why the approach that all the other frequencies used does not work. Nevertheless, the code is working and I am now running my CH552G at 6Mhz, saving a few milliamps of current.

Saatvik-Aggarwal avatar Jun 06 '23 01:06 Saatvik-Aggarwal

Thanks, this looks nice. But a clock change will require intensive testing with logic analyzer. I will test the timing then I will merge it.

DeqingSun avatar Jun 06 '23 13:06 DeqingSun