udamonic.com
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact

GPIO Module
​

This design for a GPIO module uses two NXP PCA9554Ds (datasheet) and has an onboard regulator capable of supplying 150 mA for the module. 

The module has 2x8 bits of GPIO that can user configured over the I2C bus. Up to four GPIO modules may be added to your Scamp, giving you up to an additional 64-bits of GPIO.
module_gpio.pdf
File Size: 182 kb
File Type: pdf
Download File

Schematic
The address selection switch maps the two PCA9554D in pairs to addresses in the range $24 to $27. The table on the PCB indicates switch settings and the corresponding addresses of the PCA9554Ds. Once the GPIO module is attached to your Scamp, use the modules word to scan for its presence. Each module will appear as two addresses in the address table. 

Configuring
​

The PCA9554D has four registers. 

Register 0 is the Input Port Register and is a read-only port. It reflects the incoming logic levels of the pins, regardless of whether the pin is defined as an input or an output by Register 3. Writes to this register have no effect.

Register 1 is the Output Port Register and reflects the outgoing logic levels of the pins defined as outputs by Register 3. Bit values in this register have no effect on pins defined as inputs. Reads from this register return the value that is in the flip-flop controlling the output selection, not the actual pin value.

Register 2 is the Polarity Inversion Register allows the user to invert the polarity of the Input Port register data. If a bit in this register is set (written with ‘1’), the corresponding Input Port data is inverted. If a bit in this register is cleared (written with a ‘0’), the Input Port data polarity is retained.

Register 3 is the Configuration Register and controls the direction of the I/O pins individually. If a bit in this register is set, the corresponding port pin is enabled as an input with high-impedance output driver. If a bit in this register is cleared, the corresponding port pin is enabled as an output. At reset, the I/Os are configured as inputs with a weak pull-up.

​Registers may be accessed from within your words, or directly from the command line.

The following words configure the PCA9554D at address $24 to have all 8 bits as inputs:
   start 
   $24 write .  \ begin a write to the PCA9554D and
                \ display boolean indicating success/fail
   $3 send .    \ select the config register
   $ff send .   \ configure 8 bits as input
   stop
To read from this device:
   start 
   $24 write .  \ begin a write to select the register and
                \ display boolean indicating success/fail
   $0 send .    \ select the input register
   repstart     \ restart a new I2C sequence

   $24 read .   \ read back the input
   stop
The following words configure the PCA9554D at address $25 to have all 8 bits as outputs:
   start 
   $25 write .  \ begin a write to the PCA9554D and
                \ display boolean indicating success/fail
   $3 send .    \ select the config register
   $00 send .   \ configure 8 bits as output
   stop

To output the value $aa to the second PCA9554D:
   start 
   $25 write .  \ begin a write to select the register and
                \ display boolean indicating success/fail
   $1 send .    \ select the output register
  
$aa write .  \ write $aa to the output
   stop

Site powered by Weebly. Managed by Hostwinds
  • Start
    • What is a Scamp?
    • Getting Started
    • Getting Started (Windows)
  • Learn
    • What is Forth?
    • Arithmetic
    • The Stack
    • Creating Words
    • Compilation Tricks
    • Decompilation
    • Comments
    • Characters and Strings
    • Accessing Memory
    • Constants, Variables and Values
    • Flow Control
    • Loops
    • Data Structures
    • Doubles, Triples and Quads
    • FlashForth Dictionary Reference
    • Scamp Dictionary Reference
  • Extras
    • Interrupts
    • Timers
    • Multitasking
    • Delays and Tick Count
    • Processor Words
    • Starting up with turnkey
    • Changing the Prompt
    • Formatting Text on Screen
  • Interfacing
    • Using the LED Array
    • Temperature Sensor
    • Input/Output
    • Analog Input
    • Serial >
      • Serial Communication
      • Scamp2 UART Pins
    • I2C >
      • I2C Overview
      • I2C Commands
    • SPI
    • PWM
    • Peripheral Pin Select
    • Input Capture
    • Digital Signal Modulator
  • Create
    • Creating PCBs >
      • Designing PCBs
      • Fabricating PCBs
      • Soldering
    • Sensing >
      • Measuring Temperature
    • LEDs >
      • Adding LEDs
      • LED arc-welder effect
    • Displays >
      • Adding a 7 Segment Display
      • Adding a Touch LCD
      • Touch LCD GUI
      • Game of Pong
    • Adding Extra GPIO
    • Adding a Low Side Switch
    • FizzBuzz
    • Adding MRAM
    • Model Train Control
    • Adding a Real Time Clock
    • Scamp Projects on Youtube
  • Resources
  • Store
  • About
  • Contact