Skip to content

Commit

Permalink
Increase CLKDIV for IOW because 5170 doesn't have valid data for 30ns
Browse files Browse the repository at this point in the history
  • Loading branch information
polpo committed Jan 15, 2024
1 parent 6021416 commit 9128a40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sw/isa_io.pio
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ read_addr:
.wrap

% c-sdk {
static inline void iow_program_init(PIO pio, uint sm, uint offset) {
static inline void iow_program_init(PIO pio, uint sm, uint offset, float clkdiv) {
pio_sm_config c = iow_program_get_default_config(offset);

// Set up AD0 pins as input
sm_config_set_in_pins(&c, AD0_PIN);
// Autopush at 18 bits (10 addr + 8 data)
sm_config_set_in_shift(&c, false, true, 18);
sm_config_set_clkdiv(&c, clkdiv);

// Autopull 32 bits (condition variables from handle_ior)
sm_config_set_out_shift(&c, true, true /* autopull */, 32);
Expand Down
3 changes: 2 additions & 1 deletion sw/picogus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ void err_blink(void) {
constexpr uint32_t rp2_clock = 366000;
constexpr float psram_clkdiv = (float)rp2_clock / 200000.0;
constexpr float pwm_clkdiv = (float)rp2_clock / 22727.27;
constexpr float iow_clkdiv = (float)rp2_clock / 183000.0;

constexpr uint32_t iow_rxempty = 1u << (PIO_FSTAT_RXEMPTY_LSB + IOW_PIO_SM);
__force_inline bool iow_has_data() {
Expand Down Expand Up @@ -778,7 +779,7 @@ int main()
pio_sm_claim(pio0, IOR_PIO_SM);
printf("ior sm: %u\n", IOR_PIO_SM);

iow_program_init(pio0, IOW_PIO_SM, iow_offset);
iow_program_init(pio0, IOW_PIO_SM, iow_offset, iow_clkdiv);
ior_program_init(pio0, IOR_PIO_SM, ior_offset);

#ifdef USE_IRQ
Expand Down

0 comments on commit 9128a40

Please sign in to comment.