Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cores/rp2040/Tone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void tone(uint8_t pin, unsigned int frequency, unsigned long duration) {
}
pio_sm_clear_fifos(newTone->pio, newTone->sm); // Remove any old updates that haven't yet taken effect
pio_sm_put_blocking(newTone->pio, newTone->sm, RP2040::usToPIOCycles(us));
pio_sm_exec(newTone->pio, newTone->sm, pio_encode_pull(false, false));
pio_sm_exec(newTone->pio, newTone->sm, pio_encode_mov(pio_x, pio_osr));
pio_sm_set_enabled(newTone->pio, newTone->sm, true);

_toneMap.insert({pin, newTone});
Expand Down
4 changes: 2 additions & 2 deletions cores/rp2040/tone2.pio
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
.program tone2
.side_set 1 opt

pull ; TXFIFO -> OSR, or X -> OSR if no new period
mov x, osr ; OSR -> X
; pull ; TXFIFO -> OSR, or X -> OSR if no new period
; mov x, osr ; OSR -> X

high:
pull noblock ; Potentially grab new HALFCYCLECOUNT, OTW copy from backup in X
Expand Down
16 changes: 7 additions & 9 deletions cores/rp2040/tone2.pio.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,25 @@
// ----- //

#define tone2_wrap_target 0
#define tone2_wrap 8
#define tone2_wrap 6
#define tone2_pio_version 0

static const uint16_t tone2_program_instructions[] = {
// .wrap_target
0x80a0, // 0: pull block
0x8080, // 0: pull noblock
0xa027, // 1: mov x, osr
0x8080, // 2: pull noblock
0xa027, // 3: mov x, osr
0xb847, // 4: mov y, osr side 1
0xb847, // 2: mov y, osr side 1
0x0083, // 3: jmp y--, 3
0xb047, // 4: mov y, osr side 0
0x0085, // 5: jmp y--, 5
0xb047, // 6: mov y, osr side 0
0x0087, // 7: jmp y--, 7
0x0002, // 8: jmp 2
0x0000, // 6: jmp 0
// .wrap
};

#if !PICO_NO_HARDWARE
static const struct pio_program tone2_program = {
.instructions = tone2_program_instructions,
.length = 9,
.length = 7,
.origin = -1,
.pio_version = 0,
#if PICO_PIO_VERSION > 0
Expand Down
Loading