knowledge:3d_print:2022102301
差别
这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
knowledge:3d_print:2022102301 [2022/10/23 12:01] – 弘毅 | knowledge:3d_print:2022102301 [2023/06/14 12:34] (当前版本) – 弘毅 | ||
---|---|---|---|
行 6: | 行 6: | ||
static void xflash_err_msg() | static void xflash_err_msg() | ||
{ | { | ||
- | lcd_clear(); | + | |
- | lcd_puts_P(_n(" | + | lcd_puts_P(_n(" |
} | } | ||
// " | // " | ||
- | // Before startup, the Timers-functions (PWM)/ | + | // Before startup, the Timers-functions (PWM)/ |
// are initialized by the main() routine provided by the Arduino framework. | // are initialized by the main() routine provided by the Arduino framework. | ||
void setup() | void setup() | ||
{ | { | ||
- | timer2_init(); | + | |
- | mmu_init(); | + | |
- | ultralcd_init(); | + | |
- | spi_init(); | + | |
- | lcd_splash(); | + | |
- | Sound_Init(); | + | Sound_Init(); |
- | selectedSerialPort = eeprom_read_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE); | + | |
- | if (selectedSerialPort == 0xFF) selectedSerialPort = 0; | + | if (selectedSerialPort == 0xFF) selectedSerialPort = 0; |
- | eeprom_update_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, | + | eeprom_update_byte((uint8_t *)EEPROM_SECOND_SERIAL_ACTIVE, |
- | MYSERIAL.begin(BAUDRATE); | + | MYSERIAL.begin(BAUDRATE); |
- | fdev_setup_stream(uartout, | + | fdev_setup_stream(uartout, |
- | stdout = uartout; | + | stdout = uartout; |
#ifdef XFLASH | #ifdef XFLASH | ||
- | | + | |
- | uint8_t optiboot_status = 1; | + | uint8_t optiboot_status = 1; |
- | if (xflash_success) | + | if (xflash_success) |
- | { | + | { |
- | optiboot_status = optiboot_xflash_enter(); | + | optiboot_status = optiboot_xflash_enter(); |
#if (LANG_MODE != 0) //secondary language support | #if (LANG_MODE != 0) //secondary language support | ||
- | | + | |
#endif // | #endif // | ||
- | } | + | |
- | else | + | else |
- | { | + | { |
- | | + | xflash_err_msg(); |
- | } | + | } |
#else | #else | ||
- | const bool xflash_success = true; | + | |
#endif //XFLASH | #endif //XFLASH | ||
</ | </ | ||
- | 通过查看源码,发现该错误信息是Arduino的Setup函数初始化中显示的。 | + | 通过查看源码,发现该错误信息是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); | ||
+ | uint8_t cnt = 3; // 3 address bytes | ||
+ | while (cnt--) | ||
+ | _SPI_TX(0x00); | ||
+ | uint8_t xflash_mfrid = _SPI_RX(); | ||
+ | uint8_t xflash_devid = _SPI_RX(); | ||
+ | _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.1666526514.txt · 最后更改: 2023/06/07 04:09 (外部编辑)