Blinkinlabs / ch554_sdcc

CH554 software development kit for SDCC
295 stars 70 forks source link

reconsider 24Mhz for USB CDC #26

Closed nerdralph closed 3 years ago

nerdralph commented 3 years ago

The datasheet is confusing about what voltages are supported at different clock speeds and temperatures. TA32M states >28MHz is supported in the range of -20C to 70C vs <28MHz is OK from -40C to 85C. Then in table 18.4, Fsys at 24M is specified as requiring 4.4V. I think 24M is safe with VCC >= 3V3 at normal temperature ranges. For the USB CDC example, where the MCU is most likely powered from VBUS (USB 5V), in which case 24M should be safe over the full temperature range. The benefit of 24M over 16M is much more accurate UART timing at high speeds. At 16M, the counter reload value for 115.2kbps is 9 vs an ideal value of 8.68, making the timing 3.5% slow. At 24M, the reload value will be 13 vs an ideal of 13.02, making it only 0.16% fast.

cibomahto commented 3 years ago

A faster clock speed would be great! Most of the designs I've made with the CH554 interface with 3.3V peripherals, so I have to run them at the lower voltage. It makes sense to use 5V for the reasons you mention though.

In this case, we're talking about the default frequency, right? I'm ok with setting that to a higher value, I can make a board specific define for the ones I have.

nerdralph commented 3 years ago

Yes, I'm just talking about the default. And as I mentioned above, 24Mhz at 3.3V is supported in the range of -20C to 70C.

cibomahto commented 3 years ago

Thanks!

nerdralph commented 3 years ago

You were right about 24MHz not working well at 3V3. https://github.com/DeqingSun/ch55xduino/issues/28

I'd still suggest leaving the default speed at 24MHz, perhaps with a comment in the CDC example to change it to 16MHz when the MCU is powered at 3V3.

cibomahto commented 3 years ago

Ah, oh well! Sure, a note sounds like a good idea.