View Full Version : 3 SPI Questions
rlinder
12-20-02, 06:10 AM
1) Does IsoPod support 'Slave' mode?
2) How can I select the 8 possible 'Slave Select Output' in MASTER mode ? Do I need to use GPIO pin?
3) Can one machine talk to slave 0 and the other machine talk to slave 1?
nmitech
12-20-02, 09:20 AM
1) Does IsoPod support 'Slave' mode?
The current version of IsoMax software does not support Slave mode. This
is planned for a future version. The IsoPod CPU does support Slave mode,
but for now you'll have to access this mode by directly programming the CPU
registers as required.
2) How can I select the 8 possible 'Slave Select Output' in MASTER mode ?
Do I need to use GPIO pin?
Yes, you need to use GPIO pins to produce slave select outputs. There are
four GPIO pins on the SPI connector. You can also use SS/PE7 as a fifth
slave select output, since it has no required function in Master mode.
(You use this pin as GPIO by referring to PE7, for example, PE7 ON or PE7
OFF.)
3) Can one machine talk to slave 0 and the other machine talk to slave 1?
Yes, but this will take some clever housekeeping to make sure that both
machines don't try talking at the same time. The simplest approach is to
ensure that each slave transmission is complete, and the slave is
deselected, in one operation. For example, you could use the phrase
...data to send... PD0 OFF SPI0 TX-SPI SPI0 RX-SPI DROP PD0 ON
which assumes that you have an active-low slave select on PD0. The purpose
of SPI0 RX-SPI DROP is to ensure that the SPI transmission is completed.
(Of course, if you were reading the SPI slave, you would store the received
data instead of DROPping it.)
The problem with this approach is that it will capture the program counter
for the duration of an SPI transmission. But as long as you're the SPI
master, this will be a known and fixed delay, typically just a few
microseconds.
rlinder
12-20-02, 09:51 AM
Thanks for your response.
I am going change the design so one machine will do all the SPI things.
machine 1: SPI - read the thermometers and RTC, store data. And fan control
machine 2: run the 2x16 LCD with 4 button input
machine 3: act upon data from machine 1 & 2
This is for a house cooling system usings fans.
RMDumse
12-20-02, 10:01 PM
You mentioned an LCD. Here is some code for a 4-bit LCD interface, that might help speed you along.
COLD
( ****************************************************************
( I/O PORTS
(
( I/O Ports Assign Function
( ~~~ ~~~~~ ~~~~~~~~~~~~~~~
( I/O PA0 LCD, DB4
( I/O PA1 LCD, DB5
( I/O PA2 LCD, DB6
( I/O PA3 LCD, DB7
( O PA4 LCD, RS (register select. LOW: command, HIGH: data)
( O PA5 LCD, R/W (READ: signal high, WRITE: signal low)
( O PA6 LCD, E (chip enable, active high)
( ****************************************************************
HEX
( ==== Tools ==== )
: <NIB ( d -- d' ) 2* 2* 2* 2* ;
: NIB> ( d -- d' ) 2/ 2/ 2/ 2/ ;
: DSP4@ ( -- d )
70 FB2 ! ( data in )
PA5 ON ( RD high
PA6 ON ( E high enable chip
FB1 @ 0F AND ( read data bus )
PA6 OFF ( E low disable chip
;
: DSP4! ( d -- )
7F FB2 ! ( data out )
PA5 OFF ( WR low
0F AND FB1 @ F0 AND OR FB1 ! ( output data )
PA6 ON ( E high enable chip
PA6 OFF ( E low disable chip
;
: CMD> ( -- d ) PA4 OFF DSP4@ <NIB DSP4@ OR ;
: LCD> ( -- d ) PA4 ON DSP4@ <NIB DSP4@ OR ;
: WNB ( -- ) BEGIN CMD> 80 AND 0= ?TERMINAL OR UNTIL ;
: >CMD ( d -- ) PA4 OFF DUP NIB> DSP4! WNB PA4 OFF DSP4! WNB ;
: >LCD ( d -- ) PA4 ON DUP NIB> DSP4! WNB PA4 ON DSP4! WNB ;
: DSP-INIT ( -- )
3F FB1 ! ( outputs high for R/W.A5 RS.A4 D7.A3,D6.A2,D5.A1,D4.A0)
( low for E.A6
7F FB2 ! ( DDR outputs for E.A6 R/W.A5 RS.A4 D7.A3,D6.A2,D5.A1,D4.A0)
0 FB3 ! ( release all port A lines from PER )
33 >CMD ( reset sequence for
32 >CMD ( four bit interface
28 >CMD ( 4 bit data length; 2 lines; 5x7 dots
6 >CMD ( entry mode set: increment; no shift
F >CMD ( display on; cursor on; blink on
1 >CMD ( display clear
80 >CMD ( cursor in top left position
;
: CLEAR WNB >CMD ;
: HOME WNB 2 >CMD ;
: CRLF WNB C0 >CMD ;
: MOVE-CURSOR WNB 80 OR >CMD ;
: RIGHT-UPPER-CORNER 27 MOVE-CURSOR ;
: CURSOR? WNB CMD> 7F AND ;
: DSP>L WNB 10 >CMD CURSOR? 27 > IF RIGHT-UPPER-CORNER THEN ;
: DSP>R WNB 14 >CMD CURSOR? 27 > IF HOME THEN ;
: DSP-EMIT WNB >LCD ;
: DSP-SPACE BL DSP-EMIT ;
: DSP-SPACES 0 MAX BEGIN ?DUP WHILE 1- DSP-SPACE REPEAT ;
: DSP-TYPE
BEGIN
DUP 0= NOT
WHILE
1- SWAP DUP C@ DSP-EMIT 1+ SWAP
REPEAT
2DROP
;
: .DSP ( n -- ) DUP ABS 0 <# #S SIGN #> DSP-TYPE ;
rlinder
12-21-02, 10:08 AM
What is the part name for the 4-bit LCD Display?
RMDumse
12-21-02, 10:29 AM
Pretty much all the 2x16 (etc.) intelligent displays use the same controller, which can do either nibble or byte transfers. We did the nibble for this one to conserve GPIO pins needed.
vBulletin v3.0.7, Copyright ©2000-2012, Jelsoft Enterprises Ltd.