/* uartsxx.c uart tx string created by paulie on eevblog.com 10/8/2014
01 minimum*/
#include "stm8s.h"
int tx_string(const char *str)
{ unsigned char i;
i=0; while(str[i]) { while(!(USART1_SR&USART_SR_TXE)); USART1_DR=str[i++]; }
return(i);
}
int main()
{ unsigned long l=0;
CLK_DIVR=0x00; //frequency 16 MHz #0x50c0
USART1_CR2=USART_CR2_TEN; //en TX RX #0x5235
USART1_BRR1=0x11; //368=9800 11=57k baud #0x5232
while(1) { tx_string("Hello World! "); l=720000; while (l--); } //1 sec
}
(really wishing the STM8 stuff was in a separate thread...)
Last year you might have been right but this year the shift has already begun and it is shifting towards the new low cost champion: the cortexM0
...
The single reason is that the M0 is being made in a much smaller nm chip processing technology than the STM8
Yup, the price point of cortex-M0 is going to be interesting the coming year or so. Aren't ST & NXP migrating some M0/M0+ designs from 90 nm to 40 nm? That would be even better for price per die.
So here's the interrupt-driven "Hello World."
Speaking of C, I was curious if C would generate code similar to my assembly code
Oops. The existing .ld file has an incorrect RAM amount
I should put this stuff in a github repository or something...
I should put this stuff in a github repository or something...
Did the GCC dudes make a mistake or did I pick the wrong one? [with stm32.ld]
Where exactly did yours come from?
easier on the noobs
would it be possible for you to put up the ELF file for your C version? I'm very curious about the difference compared to asm.
Disassembly of section .text.q_get:
00000000 <q_get>:
0: f890 3022 ldrb.w r3, [r0, #34] ; 0x22
4: b163 cbz r3, 20 <q_get+0x20>
6: f890 2021 ldrb.w r2, [r0, #33] ; 0x21
a: 3b01 subs r3, #1
c: 1c51 adds r1, r2, #1
e: 5c82 ldrb r2, [r0, r2]
10: f001 011f and.w r1, r1, #31
14: f880 3022 strb.w r3, [r0, #34] ; 0x22
18: f880 1021 strb.w r1, [r0, #33] ; 0x21
1c: 4610 mov r0, r2
1e: 4770 bx lr
20: f04f 30ff mov.w r0, #4294967295 ; 0xffffffff
24: 4770 bx lr
26: bf00 nop
Disassembly of section .text.q_put:
00000000 <q_put>:
0: f890 3022 ldrb.w r3, [r0, #34] ; 0x22
4: b410 push {r4}
6: 2b1f cmp r3, #31
8: d80a bhi.n 20 <q_put+0x20>
a: f890 2020 ldrb.w r2, [r0, #32]
e: 3301 adds r3, #1
10: 1c54 adds r4, r2, #1
12: f004 041f and.w r4, r4, #31
16: f880 3022 strb.w r3, [r0, #34] ; 0x22
1a: 5481 strb r1, [r0, r2]
1c: f880 4020 strb.w r4, [r0, #32]
20: f85d 4b04 ldr.w r4, [sp], #4
24: 4770 bx lr
26: bf00 nop
0000001c <q_get>:
1c: f891 0022 ldrb.w r0, [r1, #34] ; 0x22
20: 0000 movs r0, r0
22: d00c beq.n 3e <qg_exit>
24: b404 push {r2}
26: 3801 subs r0, #1
28: f881 0022 strb.w r0, [r1, #34] ; 0x22
2c: f891 2021 ldrb.w r2, [r1, #33] ; 0x21
30: 5c88 ldrb r0, [r1, r2]
32: 3201 adds r2, #1
34: f002 021f and.w r2, r2, #31
38: f881 2021 strb.w r2, [r1, #33] ; 0x21
3c: bc04 pop {r2}
0000003e <qg_exit>:
3e: 4770 bx lr
00000040 <q_put>:
40: b504 push {r2, lr}
42: f891 2022 ldrb.w r2, [r1, #34] ; 0x22
46: 2a20 cmp r2, #32
48: da0a bge.n 60 <qp_exit>
4a: 3201 adds r2, #1
4c: f881 2022 strb.w r2, [r1, #34] ; 0x22
50: f891 2020 ldrb.w r2, [r1, #32]
54: 5488 strb r0, [r1, r2]
56: 3201 adds r2, #1
58: f002 021f and.w r2, r2, #31
5c: f881 2020 strb.w r2, [r1, #32]
00000060 <qp_exit>:
60: bd04 pop {r2, pc}
Where is westfwMacros.S?
This is not the place for someone who "barely understands clicking on an attachment"...