As there isn't a demo for mcp23017.h, I thought I'd share using porta as out.
First setting the i2c address by tieing pins 15,16,17 - a0,a1,a2 hi lo. I used gcb i2c finder and it gave address as 0x40 with a0,1,2 grounded which contradicts with info but that was arduino and maybe 7bit address??
This line is important, you can't #define MCP23017_GPIOA 0
MCP23017_sendbyte( MCP23017_addr,MCP23017_GPIOA,0) ;set port a to out
The interrupt probably wrong,should be 100 Hz. https://youtu.be/PKG3Z9pjrAU
This gives 98Hz interrupt but not from the calculator..trial error
;interrupt drives motors
' Add the handler for the interrupt
On Interrupt Timer0Match1 Call InterruptHandler
Dim OCR0 AS byte alias OCR0A
Dim TCCR0 AS byte alias TCCR0B
WGM01 = 1 'Timer in CTC mode - required
' Set the correct regsisters. These registers give us the correct timed Interrupt.
' Use the TimerCalculator from MikroElectronika to obtain the correct values for these registers.
' When using the TimerCalculator from MikroElectronika paste the any registers with *_Bit registers
' Simple cut and paste from the BASIC tab
'Timer0 Prescaler = 0; Preload = 159; Actual Interrupt Time = 10 us
OCR0 = 19
TCCR0 = 0x28
TCCR0 = TCCR0 or 0x05
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
As there isn't a demo for mcp23017.h, I thought I'd share using porta as out.
First setting the i2c address by tieing pins 15,16,17 - a0,a1,a2 hi lo. I used gcb i2c finder and it gave address as 0x40 with a0,1,2 grounded which contradicts with info but that was arduino and maybe 7bit address??
This line is important, you can't #define MCP23017_GPIOA 0
MCP23017_sendbyte( MCP23017_addr,MCP23017_GPIOA,0) ;set port a to out
The interrupt probably wrong,should be 100 Hz.
https://youtu.be/PKG3Z9pjrAU
This gives 98Hz interrupt but not from the calculator..trial error