Document fait avec Nvu Document made with Nvu




Emulator 7 segments displays driver

FORTH mini system

Instructions
Use
Example

Principle

If the 7 segments displays of the emulator are addressable registers in the extension registers area of the FORTH core described as follows:

280 (0x118) display 0 (in left side)
281 (0x119) display 1
...
287 (0x11F) display 7 (in right side)

read/write:
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 making 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.

For 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:


Instructions

- CW_AFFICHEUR 280

Numero of the first extension register of the 8 7 segments displays.
This instruction does not exist in the FORTH mini system,

The access to the displays is made with the instructions I2C_PCF8574_C@,
I2C_PCF8574_C!, I2C_PCF8574A_C@ and I2C_PCF8574A_C! numeros 3 to 6.

adr_chr AFFICHEUR -

Displaying 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.

Use

The 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 and pcf8574a.txt then compile 7_segments.txt.

The following sequence is corresponding to the displaying of "12345678":

" 12345678" STRING S_NUMBER

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
.

Example

The following program installs a task which display all the possible characters:

DECIMAL

"         " STRING S_AFFICHEUR ( 8 spaces )

TACHE: T_7_SEGMENTS
 S_AFFICHEUR 1+ DUP AFFICHEUR DUP C@
 IF
  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!
  LOOP
  (Initialization of the dot with right shifting of the precedent one )
  R@ 7+ C@ DUP 127 = OVER 0= OR
  IF
   DUP XOR
  ELSE
   1+
  THEN
  ( Progressive clearing of the string when the character 127 was displayed )
  DUP R@ 7+ C! ?DUP
  IF
   7 AND R> + DUP >R C@ 128 OR R> C!
  ELSE
   R> DROP
  THEN
 ELSE
  ( Initialization of the string and task removing )
  8 32 FILL T_7_SEGMENTS T_RETIRE
 THEN
;

500 T_7_SEGMENTS 32768 OVER T_AJOUTE T_PERIODE

Here is a video: