cpldcpu/light_ws2812

ARM STM32 Problem

Closed this issue · 2 comments

Im trying to use your library with my ARM STM32F4xx and STM32F1xx Boards but i cant get it to run.
My assembler skills are not so good so i could fix the issue by myself.
I implent it like your samples but it doesnt get out of the sendarray routine. It stucks in this routine and continiously sends data out of the data port.
Im using this defines for the ports (the gpio was initialized correctly)

define ws2812_port_set ((uint32_t*)&GPIOA->BSRRH) // Address of the data port register to set the pin

define ws2812_port_clr ((uint32_t*)&GPIOA->BSRRL) // Address of the data port register to clear the pin

define ws2812_mask_set GPIO_Pin_6 // Bitmask to set the data out pin

define ws2812_mask_clr GPIO_Pin_6 // Bitmask to clear the data out pin

Hi,
do you have any way to look at the disassembly? Or can you use a debugger?
I have never tried to use the routine on an STM32...

Yes i could look at the disassembly but i cant really fiddling this out. I can paste you the most interesting part, maybe you can see it where the problem is, i can't :(

void init_ws2812_gpio(void)
{
8000b64: b580 push {r7, lr}
8000b66: b082 sub sp, #8
8000b68: af00 add r7, sp, #0
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_StructInit (&GPIO_InitStructure);
8000b6a: 463b mov r3, r7
8000b6c: 4618 mov r0, r3
8000b6e: f000 fe3d bl 80017ec <GPIO_StructInit>
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
8000b72: 2340 movs r3, #64 ; 0x40
8000b74: 603b str r3, [r7, #0]
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
8000b76: 2301 movs r3, #1
8000b78: 713b strb r3, [r7, #4]
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
8000b7a: 2300 movs r3, #0
8000b7c: 71bb strb r3, [r7, #6]
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
8000b7e: 2303 movs r3, #3
8000b80: 717b strb r3, [r7, #5]
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
8000b82: 2300 movs r3, #0
8000b84: 71fb strb r3, [r7, #7]
GPIO_Init(GPIOA, &GPIO_InitStructure);
8000b86: 463b mov r3, r7
8000b88: 2000 movs r0, #0
8000b8a: f2c4 0002 movt r0, #16386 ; 0x4002
8000b8e: 4619 mov r1, r3
8000b90: f000 fd9e bl 80016d0 <GPIO_Init>
}
8000b94: 3708 adds r7, #8
8000b96: 46bd mov sp, r7
8000b98: bd80 pop {r7, pc}
8000b9a: bf00 nop

08000b9c <ws2812_sendarray>:

void ws2812_sendarray(uint8_t *data, int datlen)
{
8000b9c: b4b0 push {r4, r5, r7}
8000b9e: b089 sub sp, #36 ; 0x24
8000ba0: af00 add r7, sp, #0
8000ba2: 6078 str r0, [r7, #4]
8000ba4: 6039 str r1, [r7, #0]
uint32_t maskhi = ws2812_mask_set;
8000ba6: 2340 movs r3, #64 ; 0x40
8000ba8: 61bb str r3, [r7, #24]
uint32_t masklo = ws2812_mask_clr;
8000baa: 2340 movs r3, #64 ; 0x40
8000bac: 617b str r3, [r7, #20]
volatile uint32_t *set = ws2812_port_set;
8000bae: 231a movs r3, #26
8000bb0: f2c4 0302 movt r3, #16386 ; 0x4002
8000bb4: 613b str r3, [r7, #16]
volatile uint32_t *clr = ws2812_port_clr;
8000bb6: 2318 movs r3, #24
8000bb8: f2c4 0302 movt r3, #16386 ; 0x4002
8000bbc: 60fb str r3, [r7, #12]
uint32_t i;
uint32_t curbyte;

while (datlen--) {

8000bbe: e028 b.n 8000c12 <end81+0x2>
curbyte=*data++;
8000bc0: 687b ldr r3, [r7, #4]
8000bc2: 1c5a adds r2, r3, #1
8000bc4: 607a str r2, [r7, #4]
8000bc6: 781b ldrb r3, [r3, #0]
8000bc8: 60bb str r3, [r7, #8]

asm volatile(

8000bca: 68ba ldr r2, [r7, #8]
8000bcc: 6939 ldr r1, [r7, #16]
8000bce: 68f8 ldr r0, [r7, #12]
8000bd0: 697c ldr r4, [r7, #20]
8000bd2: 69bd ldr r5, [r7, #24]
8000bd4: 69fb ldr r3, [r7, #28]
8000bd6: ea4f 6202 mov.w r2, r2, lsl #24
8000bda: 2308 movs r3, #8

08000bdc :
8000bdc: ea4f 0242 mov.w r2, r2, lsl #1
8000be0: 600d str r5, [r1, #0]
8000be2: e7ff b.n 8000be4 <ilop81+0x8>
8000be4: e7ff b.n 8000be6 <ilop81+0xa>
8000be6: e7ff b.n 8000be8 <ilop81+0xc>
8000be8: e7ff b.n 8000bea <ilop81+0xe>
8000bea: f080 8001 bcs.w 8000bf0
8000bee: 6004 str r4, [r0, #0]

08000bf0 :
8000bf0: e7ff b.n 8000bf2 <one81+0x2>
8000bf2: e7ff b.n 8000bf4 <one81+0x4>
8000bf4: e7ff b.n 8000bf6 <one81+0x6>
8000bf6: f1a3 0301 sub.w r3, r3, #1
8000bfa: 6004 str r4, [r0, #0]
8000bfc: f000 8008 beq.w 8000c10
8000c00: e7ff b.n 8000c02 <one81+0x12>
8000c02: e7ff b.n 8000c04 <one81+0x14>
8000c04: e7ff b.n 8000c06 <one81+0x16>
8000c06: e7ff b.n 8000c08 <one81+0x18>
8000c08: e7ff b.n 8000c0a <one81+0x1a>
8000c0a: e7ff b.n 8000c0c <one81+0x1c>
8000c0c: f7ff bfe6 b.w 8000bdc

08000c10 :
8000c10: 61fb str r3, [r7, #28]
volatile uint32_t *set = ws2812_port_set;
volatile uint32_t *clr = ws2812_port_clr;
uint32_t i;
uint32_t curbyte;

while (datlen--) {

8000c12: 683b ldr r3, [r7, #0]
8000c14: 1e5a subs r2, r3, #1
8000c16: 603a str r2, [r7, #0]
8000c18: 2b00 cmp r3, #0
8000c1a: d1d1 bne.n 8000bc0 <ws2812_sendarray+0x24>
"end%=: \n\t"
: [ctr] "+r" (i)
: [dat] "r" (curbyte), [set] "r" (set), [clr] "r" (clr), [masklo] "r" (masklo), [maskhi] "r" (maskhi)
);
}
}
8000c1c: 3724 adds r7, #36 ; 0x24
8000c1e: 46bd mov sp, r7
8000c20: bcb0 pop {r4, r5, r7}
8000c22: 4770 bx lr