make pio faster

This commit is contained in:
kbleeke 2023-03-28 14:03:17 +02:00
parent c15f07de4f
commit 781c7f978c

View File

@ -33,18 +33,23 @@ where
{ {
let program = pio_asm!( let program = pio_asm!(
".side_set 1" ".side_set 1"
// "set pindirs, 1 side 0"
// "set pins, 0 side 0"
".wrap_target" ".wrap_target"
// write out x-1 bits
"lp:", "lp:",
"out pins, 1 side 0" "out pins, 1 side 0"
"jmp x-- lp side 1" "jmp x-- lp side 1"
// switch directions
"set pindirs, 0 side 0" "set pindirs, 0 side 0"
// these nops seem to be necessary for fast clkdiv
"nop side 1" "nop side 1"
"nop side 1"
// read in y-1 bits
"lp2:" "lp2:"
"in pins, 1 side 1" "in pins, 1 side 0"
"jmp y-- lp2 side 0" "jmp y-- lp2 side 1"
// wait for event and irq host
"wait 1 pin 0 side 0" "wait 1 pin 0 side 0"
"irq 0 side 0" "irq 0 side 0"
@ -64,8 +69,15 @@ where
sm.write_instr(relocated.origin() as usize, relocated.code()); sm.write_instr(relocated.origin() as usize, relocated.code());
// theoretical maximum according to data sheet, 100Mhz Pio => 50Mhz SPI Freq
// does not work yet,
// sm.set_clkdiv(0x0140);
// same speed as pico-sdk, 62.5Mhz
sm.set_clkdiv(0x0200);
// 32 Mhz // 32 Mhz
sm.set_clkdiv(0x03E8); // sm.set_clkdiv(0x03E8);
// 16 Mhz // 16 Mhz
// sm.set_clkdiv(0x07d0); // sm.set_clkdiv(0x07d0);