Skip to content

Commit 5e31466

Browse files
committed
fixed SAM and Whitestar errors
1 parent 492e25f commit 5e31466

File tree

3 files changed

+29
-21
lines changed

3 files changed

+29
-21
lines changed

src/dmd_interface_sam.pio

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@
88

99
.program dmd_reader_sam
1010

11-
; Send using an external clock on the SPI interface
12-
; - IN pin 0 is the DATA pin
1311

14-
; initialize y with 16348 = number of pixels (128x32x4)
15-
set x, 1
16-
in x, 1
17-
in null, 15
18-
mov y, isr
12+
; initialize y with 16383, number of pixels (128x32x4) - 1 because counting starts at 0.
13+
set x, 31 ; x = 31 (max 5-bit value)
14+
in x, 5 ; shift in 5 bits, isr = 31
15+
set x, 31 ; x = 31
16+
in x, 5 ; shift in 5 bits, isr = 1023
17+
set x, 15 ; x = 15
18+
in x, 4 ; shift in 4 bits, isr = 16383
19+
in null, 2 ; pad with 2 zeros
20+
mov y, isr ; y = 16383
1921

2022
.wrap_target
2123

@@ -25,13 +27,13 @@
2527
irq clear 4
2628
wait irq 4
2729

30+
wait 1 gpio RDATA ; raising edge indicates a new frame
31+
2832
dotloop:
2933
wait 0 gpio DOTCLK ; falling edge
30-
in null, 3 ; pad with 3 zeros
34+
in null, 3 ; left padding with 3 zeros
3135
wait 1 gpio DOTCLK ; raising edge
3236
in pins 1 ; read pin data
33-
34-
3537
jmp x-- dotloop
3638

3739
.wrap
@@ -40,7 +42,7 @@ dotloop:
4042

4143
.wrap_target
4244

43-
; synchronize on the least significant plane
45+
; synchronize on a new frame
4446
wait 0 gpio RDATA
4547
wait 1 gpio RDATA
4648
irq 4
@@ -55,13 +57,15 @@ static inline void dmd_reader_sam_program_init(PIO pio, uint sm, uint offset) {
5557
// Set the IN pin, we don't use any other
5658
sm_config_set_in_pins(&c, 2); // SDATA
5759

60+
// Set the pin direction at the PIO
61+
pio_sm_set_consecutive_pindirs(pio, sm, 6, 1, false); // RDATA
62+
pio_sm_set_consecutive_pindirs(pio, sm, 2, 2, false); // SDATA, DOTCLK
63+
5864
// Connect these GPIOs to this PIO block
65+
pio_gpio_init(pio, 6); // RDATA
5966
pio_gpio_init(pio, 3); // DOTCLK
6067
pio_gpio_init(pio, 2); // SDATA
6168

62-
// Set the pin direction at the PIO
63-
pio_sm_set_consecutive_pindirs(pio, sm, 2, 2, false); // SDATA, DOTCLK
64-
6569
// Shifting to left matches the customary MSB-first ordering of SPI.
6670
sm_config_set_in_shift(
6771
&c,

src/dmd_interface_whitestar.pio

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99
.program dmd_reader_whitestar
1010

1111

12-
; initialize y with 8192 = number of pixels ((128 x LSB + 128 x MSB) x 32)
13-
set x, 1
14-
in x, 1
15-
in null, 13
16-
mov y, isr
12+
; initialize y with 8191, number of pixels ((128 x LSB + 128 x MSB) x 32) - 1 because counting starts at 0.
13+
set x, 31 ; x = 31 (max 5-bit value)
14+
in x, 5 ; shift in 5 bits, isr = 31
15+
set x, 31 ; x = 31
16+
in x, 5 ; shift in 5 bits, isr = 1023
17+
set x, 15 ; x = 15
18+
in x, 3 ; shift in 3 bits, isr = 8191
19+
in null, 3 ; pad with 3 zeros
20+
mov y, isr ; y = 8191
1721

1822
.wrap_target
1923

@@ -93,4 +97,4 @@ static inline void dmd_framedetect_whitestar_program_init(PIO pio, uint sm, uint
9397
// Load our configuration, do not yet start the program
9498
pio_sm_init(pio, sm, offset, &c);
9599
}
96-
%}
100+
%}

src/dmd_interface_wpc.pio

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
plane_loop:
2828
wait 0 gpio DOTCLK ; no DOTCLK period or faling edge of the previous
29-
in null 1 ; add a 0 to the output as WPC is 2bit/px
29+
in null 1 ; left padding a 0 to the output as WPC is 2bit/px
3030
wait 1 gpio DOTCLK ; raising edge
3131
in pins 1 ; read 1 bit pin data
3232
jmp x-- plane_loop

0 commit comments

Comments
 (0)