Author Topic: custom pcb with atmega32u4 chip not quite working after programming  (Read 3617 times)

0 Members and 1 Guest are viewing this topic.

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
I finally got my prototype batch of pcbs.  I programmed one of them and it had some erratic beahvior, but keys were registering.  I looked over the tmk_firmware for my custom board and noticed one of the pins was wrong.  fixed that, recompiled, reprogrammed.  the keyboard now shows up as a keyboard for about 2 seconds and then flips back to atmega32u4.  no keys are registering.  Anyone have any ideas?

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #1 on: Tue, 08 March 2016, 23:17:04 »
issue seems to be related to d7 pin

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #2 on: Wed, 09 March 2016, 09:53:10 »
with correct programming the board starts up as a keyboard and then flips to programming mode.  if I change the pin config for the first column and insert the error back in, the board starts up as a keyboard and stays a keyboard.  the keyboard constantly sends tab scan code.  It seems like 30% of the keys are working as expected.  Not sure what's happening.

Anyone have any experience with debugging pcb issues?

The schematic is in github https://github.com/evangs/thevan44pcb/tree/master/keyboard with the rest of the kicad files.  the pcb layout isn't up to date, will upload that tonight.

any help is appreciated.

Offline regack

  • Posts: 660
  • Location: Thessia
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #3 on: Wed, 09 March 2016, 14:46:44 »
I'll take a look this evening and see if I see anything out of the ordinary.  You're using TMK?

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #4 on: Wed, 09 March 2016, 14:48:09 »
I'll take a look this evening and see if I see anything out of the ordinary.  You're using TMK?

Thank you so much!  Yes, using TMK firmware.

Offline iss

  • Posts: 82
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #5 on: Wed, 09 March 2016, 16:24:58 »
AREF needs to be tied to ground through a 0.1uF cap.

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #6 on: Wed, 09 March 2016, 16:27:42 »

AREF needs to be tied to ground through a 0.1uF cap.

Thanks, would this be causing my issues? What does AREF do?

Offline iss

  • Posts: 82
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #7 on: Wed, 09 March 2016, 16:53:22 »
Perhaps. It sets the reference voltage, which could in theory affect pin readouts.

Can you post your TMK code?
« Last Edit: Wed, 09 March 2016, 16:54:56 by iss »

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #8 on: Wed, 09 March 2016, 16:54:27 »

Perhaps. It sets the reference voltage, which could in theory affect pin readouts, although I'd consider it unlikely.

Can you post your TMK code?

Interesting.  Will post the code when I get home tonight.  Thanks for looking into this, I appreciate the help

Offline iss

  • Posts: 82
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #9 on: Wed, 09 March 2016, 16:56:34 »
If your analog pins (ADC_) are the ones with issues, that'd probably be the reason why.

Offline regack

  • Posts: 660
  • Location: Thessia
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #10 on: Wed, 09 March 2016, 17:32:31 »

I've always left AREF floating, but I could just be lucky.


Which TMK keyboard did you start with for your firmware?  Was it the GH60 by any chance?  The only reason I ask that is the GH60 doesn't use PF4, PF5, PF6, PF7 which are the JTAG interface pins - consequently it doesn't disable JTAG on start and that will mess everything up if you're trying to use those (ask me how I know this :P).  Anyway, look in your matrix.c (around line 76 or so) at the start of the matrix_init() function... if you don't see:


    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);


at the beginning of that function, add that in to disable JTAG, then try again. 

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #11 on: Wed, 09 March 2016, 17:34:43 »


I've always left AREF floating, but I could just be lucky.


Which TMK keyboard did you start with for your firmware?  Was it the GH60 by any chance?  The only reason I ask that is the GH60 doesn't use PF4, PF5, PF6, PF7 which are the JTAG interface pins - consequently it doesn't disable JTAG on start and that will mess everything up if you're trying to use those (ask me how I know this :P).  Anyway, look in your matrix.c (around line 76 or so) at the start of the matrix_init() function... if you don't see:


    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);


at the beginning of that function, add that in to disable JTAG, then try again.

Yes I started from GH60.... Will try this and report back

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #12 on: Wed, 09 March 2016, 18:32:34 »


I've always left AREF floating, but I could just be lucky.


Which TMK keyboard did you start with for your firmware?  Was it the GH60 by any chance?  The only reason I ask that is the GH60 doesn't use PF4, PF5, PF6, PF7 which are the JTAG interface pins - consequently it doesn't disable JTAG on start and that will mess everything up if you're trying to use those (ask me how I know this :P).  Anyway, look in your matrix.c (around line 76 or so) at the start of the matrix_init() function... if you don't see:


    // To use PORTF disable JTAG with writing JTD bit twice within four cycles.
    MCUCR |= (1<<JTD);
    MCUCR |= (1<<JTD);


at the beginning of that function, add that in to disable JTAG, then try again.

Yes I started from GH60.... Will try this and report back

wow... it looks like it was the jtag thing!  board seems to be working perfectly now... gotta run some more test, but looking good so far!  thanks for your help

Offline regack

  • Posts: 660
  • Location: Thessia
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #13 on: Wed, 09 March 2016, 18:41:47 »
Great!  It was actually Grendel that figured that out for me a year or so ago, so really the credit goes to him in a roundabout way :)

Offline evangs

  • * Maker
  • Thread Starter
  • Posts: 1051
  • Location: Arizona
  • TheVan
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #14 on: Wed, 09 March 2016, 18:43:36 »
Great!  It was actually Grendel that figured that out for me a year or so ago, so really the credit goes to him in a roundabout way :)

thing is working like a charm now!  thanks to Grendel for figuring out the issue and thanks to you for passing on the info!!!!!!

Offline MOZ

  • KING OF THE NEWBIES
  • * Maker
  • Posts: 3981
  • Location: Jo'burg
  • Busy making stuff
Re: custom pcb with atmega32u4 chip not quite working after programming
« Reply #15 on: Sat, 12 March 2016, 10:38:14 »
On the Teensy the JTAG is disabled via the fuse bits and that is why the TMK software seems to run fine without any issues on it, the factory chip from Atmel has the JTAG enabled by default and thus you have to disable explicitly it in TMK.