Hi,
I'd like to use GCB to read from a 39 key keypad and write to upto 10 led's. This would use an MCP23017 port expander and a 4532 8 to 3 priority encoder (see attached example schematic-the MCP23017 replaces the SAA1061 chip). Is there any example code that uses a MCP23017 with a keypad and LED's? Thanks.
Thanks. I'm a beginner with GCB. Where can I find (which directory?) this library file and how do I include it in a listing? I can probably start with turning an LED on and OFF. Is there an example of this anywhere? I've seen a few posts in the forum about the MCP23017 but nothing that is a clear working example. I'm mostly going to writing/polling to port pins.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The library is in the include directory ..... GreatcowBasic/Include/mcp23017.h
GCB libraries end with '.h' but are the library not a header file.
It can be used by an include statement at the beginning of you code.
#include<mcp23017.h>
There is a demo file for another I2C expander under greatCowBasic/demos/I2C_solutions/I2C_serial_expanders/I2C_pcf8574_serial_expander..... .gcb
What processor will you be using? Just change the chip statement.
#chip mega328p, 16
GreatCowBasic has a very good Help page.
And use this forum to ask question. We are not usually grumpy like this past month.
GL
mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm agnostic about the chip at this stage (I'm using 16F819 or 16F1847 at the moment), but may choose a 18f series later on for the USB capability). I mainly use C (CCS C compiler) or assembly, but I've never used GCB. I've never used a MCP20317 or I2C either. I just want to start very simply with lighting 1 LED and then moving on to several LEDs and at the same time getting familiar with GCB. I guess reading the MCP23017.h file would help, but where does this header live?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The headers are loaded into the include folder. So, you do not need to worry when you start.
#chip 16F1847#include<mcp23017.h>#DEFINE MCP23017_DEVICE_1 0X40 // address 0x40 the 8 bit address;-----DefineI2CHardwaresettings#define HI2C_BAUD_RATE 100#define HI2C_DATA PORTB.4 // required pullup 4k#define HI2C_CLOCK PORTB.6 // required pullup 4kDirHI2C_DATAinDirHI2C_CLOCKinHI2CModeMaster;-----endofI2CHardwaresettings;mainprogrammcp23017_sendbyte(MCP23017_DEVICE_1,MCP23017_IODIRA,0x00)'turnallpinsoutputmcp23017_sendbyte(MCP23017_DEVICE_1,MCP23017_GPIOA,0x00)//set all offwait1smcp23017_sendbyte(MCP23017_DEVICE_1,MCP23017_GPIOA,0xFF)//set all on
This compiles. But, has not been tested.
However, does try to compile. You will get an error in the library there is a typo on line 191. All very obvious as HII2CStop should be HI2CStop(remove the II for I).
If this does work on the real hardware - you must try I2C discovery. This will confirm your setup. There are many I2C discover programs in your demos installation folder..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'd like to use GCB to read from a 39 key keypad and write to upto 10 led's. This would use an MCP23017 port expander and a 4532 8 to 3 priority encoder (see attached example schematic-the MCP23017 replaces the SAA1061 chip). Is there any example code that uses a MCP23017 with a keypad and LED's? Thanks.
Not a solution I have come across over the years I have been here. :-)
There is a library file for MCP23017. That would be a good starting spot.
Thanks. I'm a beginner with GCB. Where can I find (which directory?) this library file and how do I include it in a listing? I can probably start with turning an LED on and OFF. Is there an example of this anywhere? I've seen a few posts in the forum about the MCP23017 but nothing that is a clear working example. I'm mostly going to writing/polling to port pins.
I have working examples of the MPC23xxx functions. Let me dig them out and post here.
These are two subroutines that are used to test I2C communications of Great Cow BASIC. So, this code segment is part of a much larger test program.
Search for //!Here In GCStudio the calls will show up in RED.
This code segment shows how to setup, write and read.
The library is will documented but have you used I2C before ? What chip are you using ?
Do you have communications with the MCP ?
Evan
David,
The library is in the include directory ..... GreatcowBasic/Include/mcp23017.h
GCB libraries end with '.h' but are the library not a header file.
It can be used by an include statement at the beginning of you code.
There is a demo file for another I2C expander under greatCowBasic/demos/I2C_solutions/I2C_serial_expanders/I2C_pcf8574_serial_expander..... .gcb
What processor will you be using? Just change the chip statement.
GreatCowBasic has a very good Help page.
And use this forum to ask question. We are not usually grumpy like this past month.
GL
mike
I'm agnostic about the chip at this stage (I'm using 16F819 or 16F1847 at the moment), but may choose a 18f series later on for the USB capability). I mainly use C (CCS C compiler) or assembly, but I've never used GCB. I've never used a MCP20317 or I2C either. I just want to start very simply with lighting 1 LED and then moving on to several LEDs and at the same time getting familiar with GCB. I guess reading the MCP23017.h file would help, but where does this header live?
This is a really good read for someone new to Great Cow BASIC. https://sourceforge.net/p/gcbasic/discussion/579126/thread/d648215933/#825c
The headers are loaded into the include folder. So, you do not need to worry when you start.
This compiles. But, has not been tested.
However, does try to compile. You will get an error in the library there is a typo on line 191. All very obvious as
HII2CStop
should beHI2CStop
(remove the II for I).If this does work on the real hardware - you must try I2C discovery. This will confirm your setup. There are many I2C discover programs in your demos installation folder..
Thanks everyone,
I'll give this a try over the next few weeks. If I come across any snags, I'll come back here for help.
David