Datasheet

Table Of Contents
WARNING
These examples are outdated, and may not reflect best practices, or even assemble under the latest pioasmyou are
much better off looking at the code in pico-examples! This section will shrink with time and the "Examples" section will
grow to replace it.
TODO delete this section once each of these is replaced with a documented SDK example
3.7.1. UART with CTSn and RTSn
Ê1 .program uart_tx_cts
Ê2 .side_set 1 opt
Ê3
Ê4 .wrap_target
Ê5 ; Block until data is available
Ê6 pull
Ê7 ; Wait for CTSn to assert
Ê8 wait 0 pin, 0
Ê9 ; Initialise loop counter, assert start bit, delay for further 7 cycles
10 set x, 7 set 0 [7]
11 ; Shift out 8 bits, at 8 cycles per loop
12 bitloop:
13 out pins, 1
14 jmp x-- bitloop [6]
15 .extern entry_point
16 ; Assert stop bit. 5 cycle delay, plus 2 cycles for pull & wait
17 nop set 1 [5]
18 .wrap
19
20
21 .program uart_rx_rts
22
23 .extern entry_point
24 .wrap_target
25 ; Continue to update RTSn until we see a start bit
26 update_rts:
27 mov pins, !status ; low if RX FIFO less than threshold
28 jmp pin update_rts
29
30 set x, 7 [11]
31 bitloop:
32 in pins, 1 [6]
33 jmp x-- bitloop
34 push
35 .wrap
3.7.2. PWM (4 varieties)
In the first example, the processor initialises 'isr' to the counter top value, using the exec interface. Counter periods of up
to clocks are therefore possible. The initial PULL is used to prime the sample register (will only have to do this
once, since autopull will be enabled), and can also be performed over the exec interface to save program space.
This example uses 8-bit PWM values, but anything in the range 1…32 bits is possible by tweaking the OUT parameter.
RP2040 Datasheet
3.7. Outdated Examples 362