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
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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.Still not sure why he didn't go the resistor route and ADC, just two pins and read the voltage to tell the key....
Sorry i forgot he was making it sleep to save 1uA so he can have 2KW for the backlight!.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.
I think I'd describe it as more of a "Visual Basic meets Delphi" lite, with the emphasis on the VB part.Much of the formating of Swordfish is based on C anyway
Reason I swaped the matrix to portC is based on a suggestion made by Jon concerning the ICSP.
DEVICE=18f2420
CLOCK = 8 ' Tell the compiler what we will be setting the clock to (Mhz)
CONFIG MCLRE = OFF
'CONFIG fOSC = INTIO67 ' Internal oscillator, IO on pins 6 and 7
'INCLUDE "INTOSC8.bas"
'config "InternalOscillator.bas"
'#option LCD_DATA = PORTC.4
'#option LCD_RS = PORTC.0
'#option LCD_EN = PORTC.1
INCLUDE "SetDigitalIO.bas" // Include this file when we compile so that we can use keywords like 'setalldigital'
INCLUDE "utils.bas"
INCLUDE "convert.bas" //xxxxx
'INCLUDE "LCD.bas"
INCLUDE "keypad16pullup.bas"
INCLUDE "usart.bas"
DIM Keypressed AS BYTE
DIM Keyvalue AS BYTE
SetBaudrate(br4800)
DELAYMS(5000)
USART.Write ("Test program",13, 10, 10)
WHILE 1 = 1
Keypressed = keypad16.Value
IF Keypressed <> 0 THEN
USART.Write ("Key pressed = ", HexToStr(Keypressed), 13, 10)
END IF
WEND
How strange, I wonder why?When I compile it says KEYVALUE is declared but never used
DEVICE = 18F2420
CLOCK = 20
DIM Key AS BYTE
#option KEYPAD_PORT = PORTB
INCLUDE "Keypad16Pullup.bas"
INCLUDE "USART.bas"
INCLUDE "convert.bas"
SetBaudrate(br9600) //19200
WHILE True
REPEAT
Key = Keypad16.Value
UNTIL Key <> 0
USART.Write(DecToStr(Key),13,10)
WEND
How strange, I wonder why?
Mike.
At least they are all on the same track using the same material