knowledge:3d_print:2022102301
External SPI flash XFLASH is not responding错误分析
打印机可能会开机时候在LCD显示屏上显示External SPI flash XFLASH is not responding错误。 该错误一个最直观的影响就是Blet test操作是无法显示数值的,一直显示0. 源码文件Marlin_main.cpp 1052行 1093行 1331行均是相关代码
static void xflash_err_msg() { lcd_clear(); lcd_puts_P(_n("External SPI flash\nXFLASH is not res-\nponding. Language\nswitch unavailable.")); } // "Setup" function is called by the Arduino framework on startup. // Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code // are initialized by the main() routine provided by the Arduino framework. void setup() { timer2_init(); // enables functional millis mmu_init(); ultralcd_init(); spi_init(); lcd_splash(); Sound_Init(); // also guarantee "SET_OUTPUT(BEEPER)" selectedSerialPort = eeprom_read_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE); if (selectedSerialPort == 0xFF) selectedSerialPort = 0; eeprom_update_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, selectedSerialPort); MYSERIAL.begin(BAUDRATE); fdev_setup_stream(uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); //setup uart out stream stdout = uartout; #ifdef XFLASH bool xflash_success = xflash_init(); uint8_t optiboot_status = 1; if (xflash_success) { optiboot_status = optiboot_xflash_enter(); #if (LANG_MODE != 0) //secondary language support update_sec_lang_from_external_flash(); #endif //(LANG_MODE != 0) } else { xflash_err_msg(); } #else const bool xflash_success = true; #endif //XFLASH
通过查看源码,发现该错误信息是Arduino的Setup函数初始化中显示的。是否error是又xflash_init()函数返回的数据决定。
我们在xflash.c的51行找到该函数。他初始化XFLASH_PIN_CS引脚为SPI的CS引脚,然后执行xflash_mfrid_devid()函数判断返回。
XFLASH_PIN_CS是Arduino MEGA2560的D32引脚,也就是PC5.
int xflash_mfrid_devid(void); int8_t xflash_init(void) { _CS_HIGH(); SET_OUTPUT(XFLASH_PIN_CS); XFLASH_SPI_ENTER(); if (!xflash_mfrid_devid()) return 0; return 1; }
xflash_mfrid_devid()函数在xflash.c的193行,主要还是与Flash进行通信,获取Flash的型号。以此来确认是否通信成功。
int xflash_mfrid_devid(void) { _CS_LOW(); _SPI_TX(_CMD_MFRID_DEVID); // send command 0x90 uint8_t cnt = 3; // 3 address bytes while (cnt--) // send address bytes _SPI_TX(0x00); uint8_t xflash_mfrid = _SPI_RX(); // receive mfrid uint8_t xflash_devid = _SPI_RX(); // receive devid _CS_HIGH(); return ((xflash_mfrid == _MFRID_W25X20CL) && (xflash_devid == _DEVID_W25X20CL)) || ((xflash_mfrid == _MFRID_GD25Q20C) && (xflash_devid == _DEVID_GD25Q20C)); }
通过测试,发现该问题会有LCD2004硬件的SD卡CS到主控接触不良引起。当LCD2004的SD卡的CS到主控接触不良时,就会引起这个错误。
knowledge/3d_print/2022102301.txt · 最后更改: 2023/06/14 12:34 由 弘毅