MK312BT Firmware and function issues (Failure 20), debug suggestions?

Hi all, I’m having some issues with my newly assembled MK312-BT (PCB v1.3R) and hope someone can help. I can compile the firmware from the buttshock-et312-firmware Github repository fine, and flashed m005 to my board. The first line of characters on the display are all white (I picked a different color display) and the second line is all dark. The OUTA and OUTB lights flash slowly. I tried again with f005 and had the same result. I am using the LTC1661 DAC.

Then I tried flashing the original 312-16-decrypted.bin firmware. I see “Failure 20 Shut Off Power!!” on the display and the OUTA and OUTB lights flash, faster than when using the m005 or f005 patched firmware. Of course this original firmware requires the MAX548 DAC, so I switched the DACs on the board. Same result. Using the MAX548 and following some of the debug steps I found here, I observe a similar problem as observed by Cerb in post 8 in the same thread.

I see 9V at the drain of each MOS device and observe a 5V, 500us pulse on PB2 and PB3 at power up. Oddly enough, PB0 and PB1 show junk similar to what is observed in that thread. Different looking junk, but junk all the same. I then observe a 2V, ~500us pulse across the sense resistor R30 on power up.

Here is a scope screenshot of the pulse I see on PB2 (it’s the same on PB3). Excuse the scale, I did measure it to be 500us.

Here is a scope screenshot of the pulse I see on PB0. It’s the same as what I observe on PB1.

Here is a scope screenshot of the pulse I see across sense resistor R30.

Any suggestions as to what could be the problem, and what I should consider suspect on the board for further debugging?

What programmer are you using when you flash the atmega? Are you disconnecting the programmer before booting it up? The flashing lights can be from several different things depending on when and how they come up. If you use an adurino and don’t disconnect the programmer before boot, the programmer will take over and flash the channel lights rapidly. If the lights flash after a few button presses with the programmer disconnect then it is likely working and it’s just a display issue.

In regards to the display, ensure the 4066 is installed correctly. If you install it backwards and power up the chip is likely dead. If the chip is installed fine you might want to probe the LCD lines to see if there is a bad trace.

About the “Failure 20” message have you considered the information contained in this thread? Another Failure 20 with measurements and some test mode?
It might come down to the quality of the parts used.

I programmed the board through Atmel Studio with an Atmel ICE. I tried disconnecting the programmer and the lights still flash. I double checked and am all clear on the orientation of the CD4066. The odd part about the display is it works fine using the original firmware, but does not display any text when using the patched frankenfirmware.

Thank you for pointing me to that thread. It has helped me to understand some things here, I read the board will test channel A (through PB2 and PB3) and if it sees a failure, then won’t test channel B - this explains no activity on PB0 and PB1. It hadn’t dawned on me to trigger my scope off of the power supply -_- doing so will probably produce more useful debug information. I am using the correct IRF9Z24NPBF Infineon PMOS and Mouser supplied 42TL004. I don’t have a FET tester so I can’t verify threshold voltage. I will order a few extra anyway from various manufacturers and perhaps also try mouser and get a FET tester.

I placed R30 directly next to the uC and routed it to the 4 NMOS through a rather long trace, by quick calculator it has impedance 32mΩ. I don’t see that being a problem, but it’s also almost midnight. I will remove my R30 and replace with a 50mΩ through hole resistor and attach from the source of one NMOS to the nearest ground point since that’s the proper way to connect this anyway.

I’m giving you a lot of text and no graphics, I really need to get my good scope from gf’s house, do some more prodding, and will have a more informed update soon. That one has logic probes too so I can eliminate any suspicion of the DAC.

Please check the R30 again. 2V at 0.5 Ohm = 4A. That can not be.

I have the ASM source code for ATMEL Studio. With ATMEL Studio 4.16 and HAPSIM 2.2 it is possible to debug the code in the simulator.

After the initialization of the processor follows:
rcall initialize_lcd
rcall CallTable_24_set_initial_module_parameters_and_setup_r4to14_with_a_and_b_values
rcall get_advanced_settings_from_firmware_defaults_to_memory
rcall startup_checks_battery_checks_reset_displays_msgs; Parameter r28: r29
The voltage supply is first checked here.

Then follows the part of interest here, the calibration of the output stages.
1: DAC outputs are on the reference voltage 5.0V (SPI 0xAFF0)
2: Set DAC channel A to 4.38V (SPI 0xAE00)
3: Q1 and Q2 turn on
4: Measure voltage at R30 < 0.0782V (ADC 0x0010), representing the current through R30
5: Q1 and Q2 turn off
6: Decrease voltage DAC channel A by 0.016V
4: continue with 3rd step until voltage at R30 is 0.0782V (ADC 0x0010), maximum 64 loops,

otherwise error 20
continue with channel B

Channel_1 - DAC-Out LTC1661 PIN5 (Trigger), Channel_2 - LM358 PIN1, Channel_3 - R30
It should look like this.