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