Hi Team,
The interrupt function on the attached programme only works on the last row of the keypad, it doesn't interrupt when other
switches on the keypad are depressed?. Probably a very simple reason which I failed to understand.
Please help.
many thanks
Indana
Interrupt and keypad
Moderator: Benj
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Interrupt and keypad
Hi nmindana,
There are a few problems with your Flowchart.
1). configuration. Change settings in Expert Config Screen' (go into the configuration menu ('Chip Configure..')
click on 'Switch To Expert Config Screen') there you need to disable watchdog and LVP etc See:
viewtopic.php?f=26&t=6936
Osscon:
You only need this if using the internal oscillator. If you are using EB006 with crystal, then you can remove osccon = 0x7E;
and change Oscillator selection to HS.
2) Using Keypad and LCD with 16F88
This is more advanced. You can't just use both keypad and LCD on the same port as you have got, without disabling
Enable of LCD, change port B to input, enable port interrupt, detect keypad, Disable port interrupt, then write to LCD etc.
I have not tried this but in theory is possible
You will not be able to use either keypad OR LCD on portA, since only RA0 to RA5 is used on EB006, and RA5 on 16F88 is input only.
To Keep flowchart simple it may be best to change the target device to a different one with more pins.
3)Port Interrupt Macro. its not a good idea to call another macro from within an interrupt macro. This could lead to
corruption of code, and exceed stack usage!
When you compile to hex or to target device, you are warned about this, in the message window.
Martin
There are a few problems with your Flowchart.
1). configuration. Change settings in Expert Config Screen' (go into the configuration menu ('Chip Configure..')
click on 'Switch To Expert Config Screen') there you need to disable watchdog and LVP etc See:
viewtopic.php?f=26&t=6936
Osscon:
You only need this if using the internal oscillator. If you are using EB006 with crystal, then you can remove osccon = 0x7E;
and change Oscillator selection to HS.
2) Using Keypad and LCD with 16F88
This is more advanced. You can't just use both keypad and LCD on the same port as you have got, without disabling
Enable of LCD, change port B to input, enable port interrupt, detect keypad, Disable port interrupt, then write to LCD etc.
I have not tried this but in theory is possible
You will not be able to use either keypad OR LCD on portA, since only RA0 to RA5 is used on EB006, and RA5 on 16F88 is input only.
To Keep flowchart simple it may be best to change the target device to a different one with more pins.
3)Port Interrupt Macro. its not a good idea to call another macro from within an interrupt macro. This could lead to
corruption of code, and exceed stack usage!
When you compile to hex or to target device, you are warned about this, in the message window.
Code: Select all
Warning: function never returns: 'FCM_compare'
Building CASM file
Serious Warning: Call stack usage exceeds:8!
Call Stack Usage Report
=======================
main and Task(s): hw used:5, exceeded by:0
interrupt: hw used:6, exceeded by:0
Serious Warning: Possible sw stack corruption, function 'FCD_LCDDisplay0_Cursor' called by more than one
asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_LCDDisplay0_PrintNumber' called by more than one
asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_KeyPad0_GetKeypadAscii' called by more than one
asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'FCD_LCDDisplay0_RawSend' called by more than one
asynchronous thread (main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function 'delay_us' called by more than one asynchronous thread
(main/Task, interrupt, interrupt low)
Serious Warning: Possible sw stack corruption, function '__rom_get' called by more than one asynchronous thread
(main/Task, interrupt, interrupt low)
Memory Usage ReportMartin
- Eric Brouwer
- Posts: 20
- Joined: Sat Oct 30, 2010 10:17 am
- Has thanked: 3 times
- Been thanked: 11 times
Re: Interrupt and keypad
Using PORTB interrupt on the keypad, needs some more code before it will function correct. After the standard Keypad_GetKeypadNumber, Flowcode does not return the Column pins to the correct states to detect all possibles keys. This is why your interrupt will only work on certain rows. You will need to crate a Custom Interrupt for this function.nmindana wrote:Hi Team,
The interrupt function on the attached programme only works on the last row of the keypad, it doesn't interrupt when other
switches on the keypad are depressed?. Probably a very simple reason which I failed to understand.
Indana
Another problem is the Keypad_GetKeypadNumber command that you use in your Interrupt routine. The Keypad_GetKeypadNumber macro (under custom code) calls the delay_us macro from within your interrupt routine. This macro also gets called from the LCD macros, and will lead up to stack overflow problems. Refor to my posts under http://www.matrixmultimedia.com/mmforum ... =29&t=8413.
Although my code is not set up to use pull-up resistors, it might give you an idea to modify your own code.