I don't know what happens when you compile this, but you've used some instructions that don't exist - mov(x, 31250000). The MOV instruction can only move values between registers, it can't load an immediate value. The one instruction that can load an immediate value is SET, but that's restructed to 5 bits (ie. 0..31). The common method with PIO programs wanting arbitrary constants is to load them into whichever register you aren't otherwise using before the program starts; in your case, since you intend the PIO to be standalone and not interacting with the ARM, then both ISR and OSR are potentially available (more commonly you have a PIO program that just does input or just does output in which case OSR/ISR respectively are unused). You can create arbitrary constants by combinations of SET and shifting in the ISR/OSR to move those 5 bits to where you want them, but for most purposes that takes up too many instructions.
However, you really have to approach a problem like this by looking at what facilities the PIO has and thinking how you can map those onto your problem, rather than just writing a normal program and converting it to run on the PIO.
One thing you almost certainly want in your application is to use a large clock divider so the PIO runs slower and your delay loops can be shorter. The maximum possible divider is 64K, so if you are using the default clk_sys of 125MHz, that gives you a PIO clock of about 2kHz (ie. each PIO instruction takes 0.5ms) which is probably a convenient speed for button debouncing.
However, you really have to approach a problem like this by looking at what facilities the PIO has and thinking how you can map those onto your problem, rather than just writing a normal program and converting it to run on the PIO.
One thing you almost certainly want in your application is to use a large clock divider so the PIO runs slower and your delay loops can be shorter. The maximum possible divider is 64K, so if you are using the default clk_sys of 125MHz, that gives you a PIO clock of about 2kHz (ie. each PIO instruction takes 0.5ms) which is probably a convenient speed for button debouncing.
Statistics: Posted by arg001 — Sat Aug 03, 2024 9:06 am