Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:18 15 Jul 2025 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 : IO expander via SPI

Author Message
drkl

Senior Member

Joined: 18/10/2015
Location: Hungary
Posts: 102
Posted: 10:17pm 09 Mar 2016
Copy link to clipboard 
Print this post

Hello,

Here is a my old project rethinking...:



photo:




and the program


'SPI-16IO.BAS
'16 I/0 POINT HANDLING BY SPI
'2016.03.09--MM-V5.1
'DRK V1.0
'16 OUT: 2*HCF4094 16 IN: 2*MC14021 - BOTH ARE SHIFT-REGISTERS
'======[ INITIALISING ]================================================
OPTION EXPLICIT
OPTION AUTORUN ON
DIM K1,B1
CONST STRB=24: SETPIN STRB,DOUT:PIN(STRB)=1 'CONFIGURE DISPLAY LATCH PIN
'----------------------------------------------------------------------
'INP TO OUTP - UNCOMMENT NEXT 9 LINES
'DO
'SPI OPEN 500000,0,16
' PIN(STRB)=0
' PAUSE 1
' B1=SPI(0) 'READ FROM IN-SHREG TO B1
' K1=SPI(B1) 'B1 CONTENT WRITE TO OUT-SHREG
' SPI CLOSE
' PIN(STRB)=1
'LOOP
'----------------------------------------------------------------------
'0.5 SEC 16 BIT OUTPUT TOGGLE
DO
K1=K1 XOR 65535
SPI OPEN 500000,0,16
PIN(STRB)=0
PAUSE 1
'K1=SEND TO OUT-SHREG
B1=SPI(K1) 'B1 = THE CONTENT OF INP-SHREG
SPI CLOSE
' ? BIN$(B1,16) 'FOR TESTING
PIN(STRB)=1
PAUSE 500
LOOP
'----------------------------------------------------------------------
END


Regards

drkl
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025