main.cManufacturer Part Number Error
0805X106M6R3NTSC0915 Raspberry Pi Pico is correct.82400102 TVS arrays, and TI SN74LVC1G07QDBVRQ1.Please change C1 to a 10uF, minimum 10V, X7R, 0805 ceramic capacitor. Also confirm U1, Raspberry Pi Pico SC0915, will be manually through-hole assembled on the top side with the USB connector matching the assembly drawing.
Hello Esther,Please update C1. The quoted part0805X106M6R3NTis rated for only 6.3 V.C1 must be:
- 10 µF
- 10 V minimum
- X7R ceramic
- 0805 package
Please provide the replacement manufacturer part number for approval.Also, please confirm that U1, Raspberry Pi Pico SC0915, will be manually through-hole assembled on the top side, with the USB connector matching the assembly drawing.Finally, please have your CAM engineer confirm that all eight J2 smart-card contact areas are present on the top-copper and top-solder-mask layers and will remain exposed with no solder paste.Thank you.
Table
| Pico pin | Function | Electrical path |
|---|---|---|
| GP2 | CLK sense | 5 V CLOCK through protected 12 kΩ / 22 kΩ divider |
| GP3 | RST sense | 5 V RESET through protected 12 kΩ / 22 kΩ divider |
| GP4 | DATA sense | 5 V open-drain DATA through protected 12 kΩ / 22 kΩ divider |
| GP5 | DATA drive command | Drives SN74LVC1G07 input; high releases DATA, low asserts DATA low |
| GP6 | AUX1 sense | 5 V AUX1 through protected 12 kΩ / 22 kΩ divider |
| GP7 | AUX2 sense | 5 V AUX2 through protected 12 kΩ / 22 kΩ divider |
| GP8 | VPP sense | Confirmed 5 V maximum, through protected 12 kΩ / 22 kΩ divider |
| GP26 / ADC0 | Card VCC monitor | Card +5 V through 12 kΩ / 22 kΩ divider |
| VSYS | Pico power | Reader/card +5 V; do not connect reader +5 V to a GPIO |
22 / (12 + 22) = 0.6470588Vin = Vpin * (34 / 22)Text
VCC = adc_raw * (3.3 / 4095) * (34 / 22)
data_release() and data_assert_low() so application code keeps this release-high/assert-low contract.CMakeLists.txtCmake
cmake_minimum_required(VERSION 3.13) include(pico_sdk_import.cmake) project(pico_sle4442_emulator C CXX ASM) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 17) option(SLE4442_HIGH_FREQ_TEST "Use higher PIO sample rate for electrical testing" OFF) pico_sdk_init() add_executable(pico_sle4442_emulator main.c ) pico_generate_pio_header(pico_sle4442_emulator ${CMAKE_CURRENT_LIST_DIR}/sle4442.pio ) target_link_libraries(pico_sle4442_emulator pico_stdlib hardware_adc hardware_clocks hardware_pio ) if(SLE4442_HIGH_FREQ_TEST) target_compile_definitions(pico_sle4442_emulator PRIVATE SLE4442_HIGH_FREQ_TEST=1) endif() pico_enable_stdio_usb(pico_sle4442_emulator 1) pico_enable_stdio_uart(pico_sle4442_emulator 0) pico_add_extra_outputs(pico_sle4442_emulator)
sle4442.pioPio
.program sample_bus ; GP2..GP8 are read as one contiguous seven-bit sample. ; With shift-left configuration, the latest sample is in RX bits [6:0]. .wrap_target mov isr, null in pins, 7 push noblock .wrap .program data_drive ; One FIFO word controls GP5 through its least-significant bit. ; 1 = release external DATA, 0 = assert external DATA low. .wrap_target pull block out pins, 1 .wrap
main.cC
#include <stdio.h> #include "pico/stdlib.h" #include "hardware/adc.h" #include "hardware/clocks.h" #include "hardware/pio.h" #include "sle4442.pio.h" #define PIN_CLK_SENSE 2u #define PIN_RST_SENSE 3u #define PIN_DATA_SENSE 4u #define PIN_DATA_DRIVE 5u #define PIN_AUX1_SENSE 6u #define PIN_AUX2_SENSE 7u #define PIN_VPP_SENSE 8u #define PIN_VCC_ADC 26u #define VCC_ADC_INPUT 0u #define EXPECTED_PROTOCOL_CLOCK_HZ 50000u #ifdef SLE4442_HIGH_FREQ_TEST #define INPUT_SAMPLE_HZ 5000000u #else #define INPUT_SAMPLE_HZ 1000000u #endif #define SAMPLE_CLK_BIT (1u << 0) #define SAMPLE_RST_BIT (1u << 1) #define SAMPLE_DATA_BIT (1u << 2) #define SAMPLE_DRIVE_BIT (1u << 3) #define SAMPLE_AUX1_BIT (1u << 4) #define SAMPLE_AUX2_BIT (1u << 5) #define SAMPLE_VPP_BIT (1u << 6) static PIO drive_pio; static uint drive_sm; static inline void data_release(void) { /* GP5 high makes the non-inverting open-drain buffer output high-Z. */ pio_sm_put_blocking(drive_pio, drive_sm, 1u); } static inline void data_assert_low(void) { /* GP5 low makes the open-drain buffer sink external DATA. */ pio_sm_put_blocking(drive_pio, drive_sm, 0u); } static void init_input_sampler(PIO pio, uint sm) { uint offset = pio_add_program(pio, &sample_bus_program); pio_sm_config c = sample_bus_program_get_default_config(offset); sm_config_set_in_pins(&c, PIN_CLK_SENSE); sm_config_set_in_shift(&c, false, false, 32); /* shift left, explicit PUSH */ for (uint pin = PIN_CLK_SENSE; pin <= PIN_VPP_SENSE; ++pin) { pio_gpio_init(pio, pin); } pio_sm_set_consecutive_pindirs(pio, sm, PIN_CLK_SENSE, 7, false); /* The PIO loop is three instructions per completed sample. */ float divider = (float)clock_get_hz(clk_sys) / ((float)INPUT_SAMPLE_HZ * 3.0f); sm_config_set_clkdiv(&c, divider); pio_sm_init(pio, sm, offset, &c); pio_sm_set_enabled(pio, sm, true); } static void init_data_drive(PIO pio, uint sm) { uint offset = pio_add_program(pio, &data_drive_program); pio_sm_config c = data_drive_program_get_default_config(offset); sm_config_set_out_pins(&c, PIN_DATA_DRIVE, 1); sm_config_set_out_shift(&c, true, false, 32); pio_gpio_init(pio, PIN_DATA_DRIVE); pio_sm_set_consecutive_pindirs(pio, sm, PIN_DATA_DRIVE, 1, true); pio_sm_init(pio, sm, offset, &c); /* R14 already pulls GP5 high while the Pico is starting. Queue release before enabling the state machine to preserve the safe idle state. */ pio_sm_put_blocking(pio, sm, 1u); pio_sm_set_enabled(pio, sm, true); } static void init_vcc_adc(void) { adc_init(); adc_gpio_init(PIN_VCC_ADC); adc_select_input(VCC_ADC_INPUT); } static float read_card_vcc(void) { const uint16_t raw = adc_read(); const float adc_pin_v = (float)raw * (3.3f / 4095.0f); return adc_pin_v * (34.0f / 22.0f); } int main(void) { stdio_init_all(); sleep_ms(1500); PIO sample_pio = pio0; uint sample_sm = pio_claim_unused_sm(sample_pio, true); drive_pio = pio1; drive_sm = pio_claim_unused_sm(drive_pio, true); init_data_drive(drive_pio, drive_sm); data_release(); init_input_sampler(sample_pio, sample_sm); init_vcc_adc(); printf("SLE4442 Pico starter: expected clock %u Hz, sample rate %u Hz\n", EXPECTED_PROTOCOL_CLOCK_HZ, INPUT_SAMPLE_HZ); uint32_t previous = 0xffffffffu; absolute_time_t next_adc_report = make_timeout_time_ms(1000); while (true) { /* No CPU edge interrupts are used. PIO performs the actual sampling; the CPU drains snapshots and can be replaced by a protocol parser or DMA ring buffer in the full emulator. */ while (!pio_sm_is_rx_fifo_empty(sample_pio, sample_sm)) { uint32_t sample = pio_sm_get(sample_pio, sample_sm) & 0x7fu; if (sample != previous) { previous = sample; printf("CLK=%u RST=%u DATA=%u DRIVE=%u AUX1=%u AUX2=%u VPP=%u\n", !!(sample & SAMPLE_CLK_BIT), !!(sample & SAMPLE_RST_BIT), !!(sample & SAMPLE_DATA_BIT), !!(sample & SAMPLE_DRIVE_BIT), !!(sample & SAMPLE_AUX1_BIT), !!(sample & SAMPLE_AUX2_BIT), !!(sample & SAMPLE_VPP_BIT)); } } if (time_reached(next_adc_report)) { printf("Card VCC: %.3f V\n", read_card_vcc()); next_adc_report = make_timeout_time_ms(1000); } tight_loop_contents(); } }
Bash
export PICO_SDK_PATH=/absolute/path/to/pico-sdk
pico_sdk_import.cmake from the SDK's external/ directory into the firmware directory, or provide it through your normal SDK project setup.Bash
cmake -S . -B build cmake --build build -j
Bash
cmake -S . -B build-high -DSLE4442_HIGH_FREQ_TEST=ON cmake --build build-high -j
.uf2 file to the RPI-RP2 drive. Alternatively, flash the ELF with a supported SWD probe.Final pin map
Divider and ADC scaling
Safety rule for DATA
Files
`CMakeLists.txt`
`sle4442.pio`
`main.c`
Build and flash
Startup sequence
Extension note