reading a 4x4 switch matrix

Status
Not open for further replies.
Cheers jon got it now. So its a routine more than anything. I thought he was describing a module that set up the port. I dont do sword fish, i nearly went that way but stuck with C. Maybe one day i will give SF a try
 
Still not sure why he didnt go the resistor route and ADC, just two pins and read the voltage to tell the key....
 
Still not sure why he didn't go the resistor route and ADC, just two pins and read the voltage to tell the key....
This is a lot harder to get working when making more than one device. There are many article on selecting good values for all 8 resistors. Then there is the wake from sleep that can require some clever pin selections so the ADC peripheral and the comparator peripheral can share the same pin. You need the comparator to do the wake from sleep.

For these reasons MrDEB may find that this kind of implementation is too complex in firmware and hardware for his tastes.
 
Sorry i forgot he was making it sleep to save 1uA so he can have 2KW for the backlight!.

Honestly though I have never had problems just using the keypad like a resistor divider. Havnt used pics in ages but got used to using cap touch on sil labs or the ultra cool light sensor to do gestures.

I might download SF and take a look, i hate the mplabX ide. I like C18 as well. I know XC8 is supposed to be hitech C but seems different to me, also the old hitech IDE was way better.
 
You got any idea why he moved from port B?
Why would he need capture compare? i am sure it can wake from change. If I find proteus I will mock up what i mean.
 
The Special Edition of Swordfish is free and has generous limitations on the size of programs made. I believe some of the well-known users here use the free version.
 
You wouldn't have any problems. Much of the formating of Swordfish is based on C anyway.
 
For testing I am using a 18f4321 on a perf board.
I first need to map out the pins on the new keypad.
Reason I swaped the matrix to portC is based on a suggestion made by Jon concerning the ICSP.
 
Reason I swaped the matrix to portC is based on a suggestion made by Jon concerning the ICSP.

Back the truck up and read the words I wrote. I made no such recommendation.

I said you can't have the PICkit 2 connected to the ICSP connector when trying to read the keypad. Period.

I think it's foolish to change something you should be able to make work in 10 minutes because you can't be bothered to unplug the ICSP connector. If you can't make it work aa designed don't go adding parts (which you have put in the wrong place) and go mucking about in code you don't understand.

Piece of advice: make no changes to the keyboard module. If you think you need to change it to use a different port, you are wrong.
 
Hang on why am i reading a 18fK part when your working on another chip?? it might help if you tell us which chip you have pulled out the lucky dip box!

I would leave on port B, its designed for switches and keypads. Its got all the goodies to make that easy, with pics they put certain functions on certain ports, yes you swap about but you end up making things harder. Normally its something like Port A is ADC/cap sense etc , portB inputs etc. the ICSP is redundant once the circuit is programed, as Jonsea says just unplug it when you run, if you check the hardware first (sound familiar?) then code.....Then mistakes are code. Your way it makes it all guess work, it becomes a case of well it could be X Y Z in hardware thats wrong or it could Be ABC in software depend if its X or Y or Z you got wrong on the board.

Swapping chips is like swapping women, a new one is exciting right upto the point it nags for the first time or does something you dont like, better the devil you know .
 
Decided to use Jons suggestion and code then use a Tap 28 board with keypad on portb
using the usart, a fresh copy of keypad16 and use the usart.
tried different baud rates and all I get are ????????????????????????? When I compile it says KEYVALUE is declared but never used
 
Again, I didn't tell you to do anything except use port B. Use a pic on a breadboard, a TAP-28....tgat is irrelevant. I promised I was done helping you and I mean that, but I guess I have to help unfuckerate the mess you've made of my code.

You are using a TAP-28 board which has a location for a crystal and you've commented out the internal oscillator bs, so it is apparent that you are using a crystal.

Your clock = 8 statement means the chip is running at 8MHz. Chances you're using an 8MHz crystal are virtually ZERO. The CLOCK statement must match the crystal frequency.

Baudrate is a function of bits per second. PER SECOND. If you've told the micro it's running at a different speed, all the TIMING functions are screwed up. You know, like bits per SECOND.

Make the clock statement match the crystal frequency. Set the baud rate to 9600.

In the PICkit 2 GUI, use the UART tool, and set its baud rate to match the baud rate on the board. The BIT PER SECOND must match.

Someone else can explain what "Keyvalue not used" means. Geez oh grief, how long have you been doing this?

I'm done.
 
Got it to finally work! with a few differences in code. WHY ?? I am going to investigate and yes I doubled checked baude rate etc. Only reason Ipulled out the tap28 was I wanted to eliminate any circuit issues.
 
MrDEB has earned this. Have fun without me from here on.

Wow. Only TWO HUNDRED MESSAGES AFTER THE WORKING CODE WAS POSTED. Incredible the knowledge exchange that occurs here!

 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…