keypad with C and interrupts
keypad with C and interrupts
hi i am having trouble with the interrupt on change, C code trying to make a matrix keypad the lower part of the port is an output and the ioc pins inputs, the idea is to read the columns on the isr, then change the direction so that the outputs are inputs and do the same, the OR them together and i shold give back a number for each key, but apparently the interrupt gets triggered twice and it only returns the colummns, the rows always return 1, but if i keep pressing the keys sometimes it returns the correct number, i am posting the chart to see if you can help me find why the program isnt working
- Attachments
-
- teclado int.fcf
- (7.5 KiB) Downloaded 403 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: keypad with C and interrupts
Hello,
I don't think you can use IOC with a keypad as an output write to the IOC port pins counts as a change which would trigger the interrupt. It would probably be better to simply do a quick scan of the entire keypad every so often using say a timer interrupt to trigger the scan.
I don't think you can use IOC with a keypad as an output write to the IOC port pins counts as a change which would trigger the interrupt. It would probably be better to simply do a quick scan of the entire keypad every so often using say a timer interrupt to trigger the scan.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: keypad with C and interrupts
well i noticed that using the output icon disables the WPU and apparently also the interrupts, so i am switching the direction using the tris registers, and it works, the isr gets serviced, it's just that it is only doing half of the code, unless i press the key several times very quickly, another way of doing it would be to shit a zero and then compare until the zero reaches the input pins, but the direction swap is faster so i am trying to do it that way