7 segments displays driver
7 segments displays of the
emulator are addressable registers in
the extension registers area of the FORTH core described as follows:
(0x118) display 0 (in left side)
281 (0x119) display 1
287 (0x11F) display 7 (in right side)
bits[15..8] = 0x00
bits[7..0] = a,b,c,d,e,f,g,dp
lit segment if 1
The driver will allow to facilitate the use of these registers while
use of the real-time kernel. The principle consists in making i
possible the developer to have only to manage a simple 8 characters
string in ASCII coded.
the FORTH mini system emulator, the 8 7 segments displays are
wired on the components PCF8574 and PCF8574A of I2C port numeros 3 to 6.
The PCF8574 numero 3 is corresponding to
the first display and the PCF8574A numero 6 to the eighth display. The
electrical schematic is the following:
- CW_AFFICHEUR 280
Numero of the first
extension register of the 8 7 segments displays.
instruction does not exist in the FORTH mini system,
The access to the displays is made with the instructions
and I2C_PCF8574A_C! numeros 3 to 6.
adr_chr AFFICHEUR -
of the 8 ASCII characters.
adr_chr is the address of the first of the 8 ASCII
coded characters (8 bits by character).
If the bit 7 of the character is set to "1", the
dot of the corresponding display is lit.
driver not being integrated into the kernel, it is initially necessary
to compile the source file 7_segments.txt
before being able to use it.
For the FORTH mini
system, it is initialy necessary to compile first the I2C drivers
described in the source files pcf8574.txt
then compile 7_segments.txt.
following sequence is corresponding to the displaying of "12345678":
S_NUMBER 1+ AFFICHEUR
The driver uses a table allowing to transform each of the 8 ASCII coded
to a displaying character (0 to 127). The bit 7 of each of the ASCII
coded allows to light the dot.
following program installs a task which
display all the possible characters:
" STRING S_AFFICHEUR (
8 spaces )
T_7_SEGMENTS 32768 OVER T_AJOUTE T_PERIODE
S_AFFICHEUR 1+ DUP AFFICHEUR DUP C@
Left characters shifting )
DUP >R 1+ R@ 7 CMOVE R@ 8+ R@ DO
( Clearing of the last lit dot )
I C@ 127 AND I C!
(Initialization of the dot with right shifting of the
precedent one )
R@ 7+ C@ DUP 127 = OVER 0= OR
( Progressive clearing of the string when the character 127
was displayed )
DUP R@ 7+ C! ?DUP
7 AND R> + DUP >R C@ 128 OR
( Initialization of the string and task removing )
8 32 FILL T_7_SEGMENTS T_RETIRE