G400D IO state during program launch

I am facing again the same problem of IO non homogeneous state of IO during start up procedure.

I am working on a custom G400D based board. First prototype has been made in january. And after the third version of prototype we decided to launch a production of ten PCBs. On prototype, only 2 relays was used and now the pcb has 7 relays connected. Unfortunately I discover that there’s some problem with IO corresponding to relay 3 and 6.

Here’s is the mapping and reset state given by the atmel datasheet:
Relay 1: PC23 (PIO,I,PU,ST)
Relay 2: PC26 (PIO,I,PU,ST)
Relay 3: PB18 (PIO,I,PU,ST)
Relay 4: PC22 (PIO,I,PU,ST)
Relay 5: PC18 (PIO,I,PU,ST)
Relay 6: PC19 (PIO,I,PU,ST)
Relay 7: PD5 (PIO,I,PU)

I do not understand why PB18 and PC19 does not work like other Pins.

Are you using these to drive the relay? What does your driver circuit look like?

When I know a microcontroller IO pin is going to be in the INPUT state and likely to be floating and after my code runs, set this as an output, I always put a PULLDOWN resistor on the output to guarantee the driver does not switch on during the reset phase.

I am using an ULN2004AD to drive the relays.

You really need a pull down on each input so that when the processor resets and the GPIO is an output a floats high, the ULN2008 does not switch on the output.

I understand but there’s nothing to explain why PB18 have an other behavior than PC23 during start up. How should I know that (other than prototyping! again and again) I was assuming that if PC23 have a behavior, taken other IOs with the same reset state (as described in the Atmel datasheet) would result in the same behavior… but I am wrong…

After spending days on other tasks, I am focusing now on this issue. Acoording to the schematic, I need to pull down the io to switch off the relays.

Unfortunately. Using 10k to GND do not solve that. Let’s go for a lower value. As far as I remember, I already did this experiment several months ago without success…

Even with a pull down resistor at 2.2K it is not possible to force the IO at a low level state… Therefore I need to modify my schematic. What are U using to manage relays?

To drive relays I use a MMBT2222A (2N2222A for non SMD) and a BAT54AW diode for back EMF. I have a 4K7 in series with the base and a 10K pulldown on the processor side so that the transistor is OFF when the processor IO pin is in its input state on power up.

Hi Dave and thanks for your answer. Your solution is a widely used one and has prove its robustness. Unfortunately I am really not sure that I will be abble to pull down these IO’s during start up since they are supposed to be pulled up internally. Therefore let’s consider I pulled up all these IOs, thus I will need to have an equivalent of the ULN2004 but without inverted output. I am currently looking for a kind of darlington array with non inverted output (follower mode). Of course to facilitate the design of schematic and layout I am really constraint in terms of area and am practically sure I won’t have enough surface to add a transisor on each output to invert the IOs before going to the ULN…

I am still searching for the good component…

This one seems perfect no?


But I am not sure about source/sink mode… The coil is connected to 5V. So that a low output activate the relay. I therefore need a sink mode…

How can you pulled down the IO on power up if it’supposed to be a pulled up input internally? On my custom board, even with a 2.2k pulled down the IO’s is at 3V!

After tons of investigations, there’s something wrong with the product!

Here’s the last test:

I am using G400HDR and a G400D.

I want to use the following IOs:
PC23, PC26, PB18, PC22, PC18,PC19 and PD5.

All these IOs are refered as PIO,I,PU,ST as reset state except for PD5 that is PIO,I,PU only.

This supposes that all these IOs are pulled up input during startup. As inputs I should be able to pull them down or up. Pulling them up works but pulling them down does not work for PB18 and PC19. Please GHI can you confirm that?

@ leforban - We are investigating and will let you know.

@ leforban -

Confirmed :).
Try to use G400 Bootloader (https://www.ghielectronics.com/community/forum/topic?id=20215) then your issue should be gone.

Is it a new bootlader referenced? As far as I remember this is the bootloader that I already use (unless U modify the target of the link)

No, there is no new bootloader. We released only 1 version until now, if I remember correctly. We are talking G400 Bootloader 2.0, not tinybooter.
If you still see the issue meaning you are still using the version without bootloader.