2024-12-03 06:48 AM - edited 2024-12-03 06:54 AM
I'm trying to figure out some unexpected behavior (that I've posted about before) after successfully implementing alternation between T2T Card Emulation and Reader/Writer such that they seem simultaneous to the end user.
During device initialization, my code goes through the following series of events:
I've posted before about the difficulties I've faced with Adjust Regulators; it now works reliably with several layers of fallbacks. One of these fallbacks is to enable Tx/Rx beforehand; I don't know why, but it results in Adjust Regulators succeeding more frequently.
However, when I do enable Tx/Rx beforehand (setting rx_en and tx_en), it results in an interrupt. So far as I can tell, this shouldn't happen. I know for certain that it's directly because of this command—I put logs between every single line, and it's immediately afterward. It's also only because of tx_en; if I just set rx_en, no interrupt is raised.
When I then read the IRQ registers afterward, no bit is set. For the sake of debugging, no IRQs are masked, and even if they were, they should show up in the bytes read. Additionally, when I read the IRQ registers, the interrupt line is cleared!
See the logs below for an example of the IRQ being raised, no bit set, and clearing when read.
Something's fishy here, and I'm not sure what. Please let me know why this behavior is occurring.
[00:00:15.237,365] <dbg> st25r3916: adjust_regulator: Default voltage byte: 0xf
[00:00:15.237,396] <dbg> st25r3916: adjust_regulator: IRQ pin pre-enable: 0
[00:00:15.237,701] <dbg> st25r3916: irq_modify: Interrupts modified, current state 0x00000000
[00:00:15.237,731] <dbg> st25r3916: adjust_regulator: All IRQs enabled
[00:00:15.238,220] <wrn> st25r3916: IRQ
[00:00:15.238,281] <dbg> st25r3916: adjust_regulator: Enabled rx/tx successfully
[00:00:15.238,342] <dbg> st25r3916: adjust_regulator: IRQ pin: 0
[00:00:15.238,708] <dbg> st25r3916: irqs_read: Interrupts read, status: 00000000
[00:00:15.238,739] <dbg> st25r3916: adjust_regulator: IRQs: 0x00000000
[00:00:15.238,800] <dbg> st25r3916: adjust_regulator: IRQ pin: 0
[00:00:15.238,830] <dbg> st25r3916: adjust_regulator: Waiting up to 15 ms for regulator adjust
[00:00:15.239,135] <dbg> st25r3916: irq_modify: Interrupts modified, current state 0x00000000
[00:00:15.244,476] <wrn> st25r3916: Interrupt for 0x00008000 not received in time 5 ms
[00:00:15.244,689] <wrn> st25r3916: IRQ
[00:00:15.244,812] <dbg> st25r3916: irq_modify: Interrupts modified, current state 0x00008000
[00:00:15.245,178] <dbg> st25r3916: irqs_read: Interrupts read, status: 00008000
[00:00:15.245,239] <dbg> st25r3916: adjust_regulator: Adjust Regulators command err: 14
[00:00:15.245,269] <dbg> st25r3916: adjust_regulator: IRQ read err 0 and IRQs: 0x00008000
[00:00:15.245,605] <inf> st25r3916: Adjust Regulators executed without an IRQ, voltage byte: 0x8
[00:00:15.246,398] <dbg> st25r3916: adjust_regulator: Power supply voltage after adjustment 2700 mV
2024-12-03 07:01 AM
Follow up after checking again this morning: now the IRQ pin goes high after the interrupts are read. This shouldn't be possible so far as I'm aware.
[00:00:16.156,463] <dbg> st25r3916: adjust_regulator: IRQ pin pre-enable: 0
[00:00:16.156,768] <dbg> st25r3916: irq_modify: Interrupts modified, current state 0x00000000
[00:00:16.156,799] <dbg> st25r3916: adjust_regulator: All IRQs enabled
[00:00:16.157,257] <wrn> st25r3916: IRQ
[00:00:16.157,348] <dbg> st25r3916: adjust_regulator: Enabled rx/tx successfully
[00:00:16.157,379] <dbg> st25r3916: adjust_regulator: IRQ pin: 0
[00:00:16.157,775] <dbg> st25r3916: irqs_read: Interrupts read, status: 00000000
[00:00:16.157,806] <dbg> st25r3916: adjust_regulator: IRQs: 0x00000000
[00:00:16.157,836] <dbg> st25r3916: adjust_regulator: IRQ pin: 1
[00:00:16.157,897] <dbg> st25r3916: adjust_regulator: Waiting up to 15 ms for regulator adjust
2024-12-03 07:48 AM
Hi,
interrupt is fully asynchronous, can come any time even during reading/writing registers. Maybe your code is not meeting the timings which you expect?
Again: Please look at it using a logic analyzer. You can also share traces (e.g. Saleae or others) here.
And may still worth to look also from analog: Field probe and power supply VDD_RF to see the effect of the algorithm from the outside.
Ulysses
2024-12-18 10:46 AM - edited 2024-12-18 10:46 AM
I have some traces attached that I got earlier this week, digital and analog, although I now realize that I must not have had the IRQ line attached securely enough because it's low for the entire timespan. This specific trace was to figure out why initialization was failing; I set a 1ms sleep between each first command (Set Default), which you can fail at the start of the trace, then succeed 1ms later.
I recognize the analog traces look pretty shaky - I wouldn't put too much stock in those since it's just from the logic analyzer, and with extra capacitance from the wires soldered on to observe.
I'm working on a high priority bug (see my next question!) right now so I won't have time to get better traces, but I am for sure still seeing this issue. Specifically, when I have the interrupt bits printed out, during a no-response event (sends out a wake request, no response back), I see 0 -> NRE + TXE + -> 0. See the log below.
[00:00:16.051,544] <inf> nfc_mgr: NFC Reader Mode started
[00:00:16.052,032] <dbg> st25r3916: st25r3916_irqs_read: Interrupt read complete: 00000000
[00:00:16.052,093] <inf> nfc_reader: No actionable IRQs: 0x00000000
[00:00:16.054,992] <dbg> 25r3916: irq_modify: Interrupts modified, current state 0x00000000
[00:00:16.055,694] <dbg> st25r3916: st25r3916_irqs_read: Interrupt read complete: 00004008
[00:00:16.056,243] <dbg> st25r3916: st25r3916_irqs_read: Interrupt read complete: 00000000
[00:00:16.056,335] <inf> nfc_reader: No actionable IRQs: 0x00000000
[00:00:16.056,396] <inf> nfc_reader: Terminating read sequence
I don't know if there's a whole lot from this post that will help you answer my question, but once I have some time I intend to get better traces and track this problem down.
2024-12-19 07:53 AM
Hi,
hard to follow without IRQ line. Will wait for updated traces.
Ulysses