I had Gemini Deep Research AI-Generate this report on the display protocol. Seems to be useful:
Bafang Display Protocol
Bafang Display Protocol
This only describes the programming mode. That doesn't help, as we only need the normal working mode. But your first log will help, I'll take a deeper look at the weekend!Seems to be useful:
Which display are you using exactly?but I also get Err 30
Hm, your display sends a lot of unknown commands. We would need an original Bafang controller, to see, what is answered on this commands to emulate the "right" answers.I'll take a deeper look at the weekend!
The most complete list of commands seems to be in the Bafang firmware of Daniel Nilsson.Controller just replies in weird ways... no checksum as far as I can tell, but either just the same value twice or with 0x20 added)
Command | Number of messages sent | Meaning of the command |
0x08 | 10 | CMD_PEDAL_MOV |
0x0A | 8 | CMD_AMPS |
0x0B | 8 | CMD_PAS_LEVEL |
0x11 | 8 | CMD_BATT_SOC |
0x1A | 4 | BF_CMD_LIGHT |
0x1F | 4 | BF_CMD_WHEELDIAM |
0x20 | 9 | CMD_WHEEL_RPM |
0x21 | 8 | unknown |
0x22 | 8 | OPCODE_BAFANG_DISPLAY_READ_RANGE |
0x30 | 8 | unknown |
0x31 | 8 | CMD_MOVING |
0x60 | 2 | unknown |
0x62 | 2 | unknown |
0x63 | 2 | unknown |
0x64 | 2 | unknown |
0x65 | 2 | unknown |
0x66 | 2 | unknown |
0x67 | 2 | unknown |
0x90 | 2 | CMD_VERSION |
Sorry for the delay: had to get a logic analyzer to be sure, and I found out what the problem was in case you are still interested: the series resistors on my spintend rx and tx line proved faulty, which made uart erratic. So nothing to do with your codeIt is save to flash by the STLink, the hex/bin files include the bootloader.
But make sure, that you make a "full chip erase" with the STM32 Utility (or other tools), to clean the pages, that are used as EEPROM. Otherwise the old setting will still be there.