Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:43 28 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : port expander

     Page 2 of 2    
Author Message
stanleyella

Guru

Joined: 25/06/2022
Location: United Kingdom
Posts: 2129
Posted: 08:21pm 11 May 2023
Copy link to clipboard 
Print this post

@lizby - hi. I tried your code and it works. Thanks, it would have taken me ages and then probably give up.
I used a picomite non vga set up for ssd1306 oled pins 21 and 22 so had to comment some of your code.
You've given me the code to use this device. I will test for input.
Useful for others. Nice one sir :)

const mcp23017 = &h20 ' A2, A1, A0, R/W all connected to 0V
Const i2caddr=mcp23017
const IODIRA = &h00 ' Port A IO Direction register DEFAULT = I/P
const IODIRB = &h01 ' Port B IO Direction register DEFAULT = I/P
const IOCON = &h0A ' IO Expander config register - address &h0B accesses  same register
const GPIOA = &h12 ' Port A General purpose register
const GPIOB = &h13 ' Port B General Purpose register
const OLATA = &h14 ' Port A latch register
const OLATB = &h15 ' Port B latch register
const GPUPA = &h0C ' Port C pull-up register
const GPUPB = &h0D ' Port B pull-up register
I2C WRITE MCP23017,0,2,IODIRA,0 ' set direction to output
I2C WRITE MCP23017,0,2,IODIRB,0 ' set direction to output
do
mcp17
loop
sub mcp17
for i = 1 to 6
  I2C Write MCP23017,0,2,OLATA,&b10101010 '  
  I2C Write MCP23017,0,2,OLATB,&b01010101 '  
  PAUSE     1000
  I2C Write MCP23017,0,2,OLATA,&b01010101 '  
  I2C Write MCP23017,0,2,OLATB,&b10101010 '  
  PAUSE     1000
Next i
I2C Write MCP23017,0,2,OLATA,0 ' turn all off
I2C Write MCP23017,0,2,OLATB,0 ' turn all off
pause 1000
end sub
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024