STM8S105K4 PWM question

27 views
Skip to first unread message

Scott Baker

unread,
Jun 14, 2025, 3:41:32 AMJun 14
to dorkbotpdx-blabber
Hi,

I've started a new project using an STM8S105K4 dev board using the sdcc compiler.
I have never used this microcontroller or this toolset before.

I got the UART working and also the ADC, but I can't seem to get PWM working.
I'm running the PWM using Timer 1 and I'm expecting the PWM output on PC1.

Anyone have any experience with the STM8S105K4 have time to look at this code?
I can post the code if anyone is interested.

Regards,
Scott

Scott Baker

unread,
Jun 14, 2025, 6:53:13 PMJun 14
to dorkbotpdx-blabber
AI is a game changer.
After a few rounds of prompts Gemini AI located the bug and now the code works.

Regards,
Scott

Nolan Hergert

unread,
Jun 15, 2025, 2:14:15 AMJun 15
to dorkbotpdx-blabber
On the other hand, Gemini and ChatGPT kept insisting that the DMA on my chip could access the GPIO banks when I kept getting transfer errors. Turns out this isn't the case for most Cortex-M0+ processors and it's unfortunately not intuitive from the manual either. The only mention in the 1000-page reference manual is in this chart, and interestingly the timers can toggle GPIO just fine.

system_diagram.jpg

It's 80% correct for 95% of everything else though, so trust but verify. I love the rush too!

Scott Baker

unread,
Jun 15, 2025, 5:01:53 AMJun 15
to dorkbotpdx-blabber
Hi Nolan,

Yes, in my case too it made code suggestions that didn't make sense, so you have to know enough to ignore those
and guide it into doing the right thing.

For example,  at one point it suggested that I change the I/O pin assignment to match the control register that I was writing
but this would have required writing the option byte to change the pin assignment, which is a rabbit hole I didn't want to go down,
so I had to ask it "wouldn't it be easier to change the registers to match the currently assigned (default) pin?"
And it said "yes, of course, that would be another solution" and then gave me the corrected control register value to write.

So, it's not perfect, but it was still a big time saver.

Regards,
Scott
Reply all
Reply to author
Forward
0 new messages