mega644 and PC keyboard on Int0

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's a strange one.

I've sucessfully used the interface code from the Atmel app note to decode data from a PC keyboard on mega16 and mega162, but migrating the code to the mega644 has been difficult. I'm wondering if anyone else has successfuly used the old routines on a mega644.

Currently, I have to press a key 11 times for the routine to decode the key correctly. This lead me to believe my interrupt wasn't working correctly, but after the 11th key press, it will decode keys correctly for 13 more key presses, then it quits working again. The cycle is repeatable after RESET.

I'm using the latest releases of Studio and WINAVR, but went back and compiled with an older version just in case, with the same result.

Any suggestions?

Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is your processor really running at the speed you think it is, ir could it be running at 1MHz?

It is hard to tell without seeing the code. Are there any clues in the migration document, re different timer setups? Could the move of I/O registers to "high" space beyond IN/OUT reach be causing a race or non-atomic operations?

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The processor is running at 8mhz, checked it by running a set PWM timer routine (also taken from my mega162 code)and looking at the output on a scope. I tried disabling the timers just in case they were interfering with the Int0 routine, but it didn't change anything.

I tried a different interrupt routine and checked that it was seeing each edge of the data clock, and it was.

It's almost like some kind of framing error. Maybe my keyboard buffer pointer is getting lost somewhere.

Scott

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yep, buffer pointers not initialized.....

nevermind.

Scott