area-8051 / stcgal-patched

stcgal patched to support STC8G, STC8H, STC8A8K64D4 and STC32G.
16 stars 4 forks source link

Expecting support for STC32G #1

Closed liricliu closed 2 years ago

area-8051 commented 2 years ago

I have a few STC32G12K128-Beta and STC16F40K128, and I tested them this afternoon. Both respond when using the "-P stc8d" option. I'll see if I can get STCGAL to auto-detect the protocol.

area-8051 commented 2 years ago

Done.

area-8051 commented 2 years ago

Frequency trimming and firmware upload work with the STC32G12K128. Frequency trimming fails with the STC16F40K128. Unfortunately, I couldn't play with the STC32G as SDCC doesn't support MCS-251 MCU. I'll look at SDCC's sources to see if I could add it.

liricliu commented 2 years ago

Keil's compiler can only output hex386 format flash file, if you can support this format then it may works.

area-8051 commented 2 years ago

Thanks a lot for this information! I've found enough detail about hex386 to start working on it. BTW, I have neither Keil's compiler, nor Windows (I use SDCC on Linux). Could you please send me a test hex386 file? One that just blinks an LED would be perfect, so that I'll be able to see if the uploaded firmware is functional. I've added my email address to README.1st.

liricliu commented 2 years ago

I didn't see email address in README.1st, so I paste the hex code straightly in this comment. I wish it will be useful.

:0200000400FFFB :08007C0001020408102040807D :0D006F0053B3FE53B4FE75CB0075CC0022D8 :1000030075E900A9D7BA12006FC2C07E340002128C :1000130000427EA300080A3A2E34007C7A71827A69 :100023006183E49364FFF5E87CBA047AB300087E45 :0F003300730008BE700728D3E47AB3000880CCAE :020042007D231C :100044007E340F8C7D131B147D3178F87D121B14C4 :040054007D2178ECA6 :010058002285 :03000000020059A2 :100059007584017E44041FE47A49B01B4478F97E13 :03006900F8000894 :03006C000200038C :00000001FF

This will output several 28Hz PWM waves on pin P60 to P67.

area-8051 commented 2 years ago

Thanks a lot!

area-8051 commented 2 years ago

Hi Liu,

I've made a few changes and it should work now. An important difference with the STC8 is how flash space is allocated for EEPROM emulation (EEPROM space starts at 0xfe0000, instead of immediately after the last code sector). Surprisingly, the STC32G12K128 accepts 16-bit offsets for the code, which starts at 0xff0000. The way the documentation is written makes me think we should expect changes in other STC32G models.

As I have a DIP40 STC32G12K128, I have no P6, so I couldn't check the PWM waveforms, but I'm confident enough in my changes to ask you to try. :)

liricliu commented 2 years ago

I've tested the recent version and confirmed it works well. Thanks a lot!