Hello, I'm writting a CLRC632 driver for an ATmega1284. For a while, trace were sent to a VFD screen but there is a lot of information and this screen is too little to be usable.
Thus, I have configured a serial port with RTS/CTS lines with avr-usart-lib . My config contains : #define RX_STDIO_GETCHAR_ECHO #define RX_NEWLINE_MODE 2 #define USART_PUTHEX_IN_UPPERCASE #define USART_EXTEND_RX_BUFFER #define USART_SREG_SAVE_REG_NAME G_sreg_save #define USART_SREG_SAVE_REG_NUM "r4" #define USART_Z_SAVE_REG_NAME G_z_save #define USART_Z_SAVE_REG_NUM "r2" #define RX_BUFFER_SIZE 32 #define TX_BUFFER_SIZE 32 #define NO_USART1 // disable usage of uart1 #define NO_USART2 // disable usage of uart2 #define NO_USART3 // disable usage of uart3 #define CTS0_DDR DDRD #define CTS0_PORT PORTD #define CTS0_PIN PIND #define CTS0_IONUM 2 // pin number #define RTS0_DDR DDRD #define RTS0_PORT PORTD #define RTS0_PIN PIND Other lines of config header have not been modified. My collision detection doesn't run as expected, thus I have added some debug trace. For example : ... acf.sel_code = ISO14443A_AC_SEL_CODE_CL1; (*tag).state = ISO14443A_STATE_ANTICOL_RUNNING; (*tag).level = ISO14443A_LEVEL_CL1; unsigned char t[3]; snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0)\r\n"); snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0.0)\r\n"); cascade: rx_len = sizeof(sak); snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0.1)\r\n"); iso14443a_code_nvb_bits(&(acf.nvb), 16); snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0.2)\r\n"); snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0.3)\r\n"); stty_print("Anticol ACF\r\n"); ... When this program is executed, I obtain in serial line: Booting firmware 2021052014 SPI initialized CLRC632 initialization CLRC632 reset done CLRC632 wait for ready CLRC632 ready CLRC632 wait for ready CLRC632 ready CLRC632 initialized Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA 1 (0) 15 (0.0) <- why 15 and not 1 ? 15 (0.1) 15 (0.2) 15 (0.3) Anticol ACF Anticol SAK SAK=08 15 (2) 10 Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA Anticol REQA/WUPA 1 (0) 15 (0.0) 15 (0.1) 15 (0.2) 15 (0.3) Anticol ACF Anticol SAK SAK=08 15 (2) 10 Anticol REQA/WUPA stty_print() is a trivial function : void stty_print(unsigned char *t) { while((*t) != 0) { uart_putc(*t); t++; } return; } If I remove one snprintf() : snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0)\r\n"); stty_print(t); stty_print(" (0.0)\r\n"); cascade: rx_len = sizeof(sak); snprintf(t, 3, "%d", (*tag).level); stty_print(t); stty_print(" (0.1)\r\n"); iso14443a_code_nvb_bits(&(acf.nvb), 16); I obtain : 1 (0) 1 (0.0) 19 (0.1) 19 (0.2) 19 (0.3) Now my question. Why tag->level value is modified by snprintf() ? There is no concurrent thread. Information or help will be welcome. Best regards, JB