Display and buttons both working

A project log for 8051 tuner

A 3-octave tone generator using an 8051 MCU

Ken YapKen Yap 01/08/2019 at 01:550 Comments

Strangely when it came to trying out the display with the buttons, the latter failed to work. It's so dispiriting when something that worked before doesn't now. The behaviour was really bizarre, it was as if something was cancelling my button depressions. This puzzled me greatly. How could the addition of the display change the behaviour of the buttons? The outputs are driven by port 1, while the buttons are read by port 3.

Eventually it occurred to me to grep for all instances of P3 in my C code. Lo and behold, I had forgotten that a while back, in anticipation of debugging with a simulator, I had added a line to set P3 to the data being sent to the LCD display so that I could see the data by watching P3. I had forgotten that P3 is an input port, so not as benign as I thought. The reason it didn't happen before was I had tested the buttons without the LCD display.

I fixed the code and now everything works according to specification.

You can watch a video here showing the tuner running down the scale chromatically and the display showing the note being played.

I have something else to say about delay routines in drivers in the next log, then I can mark the project completed.