vdudouyt / sdcc-examples-stm8

57 stars 28 forks source link

Caveat about memory layout #3

Open midnight-wonderer opened 9 years ago

midnight-wonderer commented 9 years ago

Continued from issue #2 When I investigate further. I found that the code is misleading.
Here the issue

CLK_DIVR = 0x00; // Set the frequency to 16 MHz

When I read this line I perceive that master frequency is set to oscillator frequency but it actually is not. Because memory offset of my device is different than the example. Check page 34 of this reference. Which is entirely different from your defined SFR And since people who interested in this repo are mostly beginners just want to get started on stm8. Chance are they (me too) don't aware of the issue.

You'd better add some caveat about the SFR definition to the repo probably in the code comment.

rohitk-singh commented 9 years ago

Hi, Actually, the header file by @vdudouyt is for STM8L series. And you are using STM8S series. It probably just-works for LED Blinky and simpler projects, but would fail for peripherals with different memory mapped addresses.

midnight-wonderer commented 9 years ago

I don't even know there is l serie exist. That why I don't understand the l suffix of file name. Totally beginner.

BobRyan530 commented 7 years ago

I've modified the header to match the stm8s series. https://github.com/BobRyan530/stm8s/blob/master/stm8s.h

Note that I renamed the USART_xx registers to UART_xx to match the datasheet. Other than that some of the register values were adjusted but the names remain the same.

midnight-wonderer commented 7 years ago

@BobRyan530 nice work
I actually maintain my own version of stm8s header for the time being.
https://github.com/MidnightWonderer/stm8-header I defined only what I use, though.
If you interested I can add what you use via pull request.
I try to conform to the datasheet and the original header as possible so I use base addresses and offsets.
stm8l is actually welcome too I just haven't use it yet.

BobRyan530 commented 7 years ago

Feel free to pull whatever you'd like. Using offsets the way you are makes sense to me. Do you happen to know if the bit values in each register are consistent across the entire stm8s range? Adding all of those definitions is a daunting task but if it's universal maybe we can crowd source an effort to get it done and verified.

I didn't see any licensing on the stm8l.h file I used as a base to start my work. If we can get some clarification on that I'd like to attach a (MIT/BSD-type) license to this project

On Sun, Mar 26, 2017 at 2:56 AM, Sarun Rattanasiri <notifications@github.com

wrote:

@BobRyan530 https://github.com/BobRyan530 nice work I actually maintain my own version of stm8s header for the time being. https://github.com/MidnightWonderer/stm8-header I defined only what I use, though. If you interested I can add what you use via pull request. I try to conform to the datasheet and the original header as possible so I use base addresses and offsets. stm8l is actually welcome too I just haven't use it yet.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vdudouyt/sdcc-examples-stm8/issues/3#issuecomment-289269779, or mute the thread https://github.com/notifications/unsubscribe-auth/ACoLP-8f8gVJf1LAaXfDxl7r24sI7Tocks5rpjZEgaJpZM4FvPY5 .