Products > Programming
Setting up Arduino I/O pins?
metertech58761:
So, I'm trying to see if I can rewrite this block of 6801 assembly into C++ so as to use something like Arduino - the assumption being I'd go with something like the Mega 2560.
I'm now at the point where I have to define and add calls to the I/O lines to replace the PIA calls currently in the code.
Getting an idea as to how to set them up will help me immensely. Here are the lines I need to define (23 in all!):
I2C_Clk and I2C_Dat - obviously, this would be for the LCD (4 rows / 20 cols)
KB_R0...R3 and KB_C0...C3 are for the 4x4 matrix keyboard (8 lines total)
Init_En is an output to control one of the features (to drive a small signal relay)
Sig_PIA is a serial data input that is sampled via an interrupt
PAI is the corresponding serial data output (manipulated by the same interrupt process)
PAE (also controlled within the interrupt process) controls a relay that puts the unit in transmit or receive mode.
RlyA... RlyD are four lines that are read as a nybble to determine the status of a set of relay outputs
SW0 / SW1 are a pair of lines to determine the test switch setting (yielding a value between 0 and 3)
Likewise, Jmp0 / JMP1 are a pair of lines that check a pair of configuration jumpers (again, yielding a value between 0 and 3)
And if possible, a 'reference' crystal oscillator input.
retiredfeline:
You have to set up pins in suitable modes, input, input with pullup/pulldown, output, open drain, etc. Some pins even have to be switched between modes on the fly, e.g. the I2C SDA.
metertech58761:
--- Quote from: retiredfeline on December 01, 2021, 03:05:28 am ---You have to set up pins in suitable modes, input, input with pullup/pulldown, output, open drain, etc. Some pins even have to be switched between modes on the fly, e.g. the I2C SDA.
--- End quote ---
...and I accomplish this how?
All I've been able to find is a passing mention of the digitalWrite() command.
And I need to read several of the lines as bit pairs or a nybble.
retiredfeline:
https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/
For greater control and to read more than one pin at a time, you need to go lower level:
https://www.arduino.cc/en/Reference/PortManipulation
westfw:
--- Quote ---Here are the lines I need to define (23 in all!):
--- End quote ---
Note that the popular Arduino Uno and Arduino Nano boards only have 20 IO pins...
--- Quote ---I2C_Clk and I2C_Dat - obviously, this would be for the LCD (4 rows / 20 cols)
--- End quote ---
Use the Arduino "Wire" library (and the hardware I2C pins) Or perhaps just an existing LCD library.
--- Quote ---Sig_PIA is a serial data input that is sampled via an interrupt
PAI is the corresponding serial data output (manipulated by the same interrupt process)
PAE (also controlled within the interrupt process) controls a relay that puts the unit in transmit or receive mode.
--- End quote ---
Is this UART-compatible serial data, or something custom? The Arduino chips all have a lot more peripherals built-in than a 6801, so it's hard to tell which features of your old board should be moved to hardware, and which you want to reproduce the old software-driven behavior.
--- Quote ---Init_En is an output to control one of the features (to drive a small signal relay)KB_R0...R3 and KB_C0...C3 are for the 4x4 matrix keyboard (8 lines total)RlyA... RlyD are four lines that are read as a nybble to determine the status of a set of relay outputsSW0 / SW1 are a pair of lines to determine the test switch setting (yielding a value between 0 and 3)
Likewise, Jmp0 / JMP1 are a pair of lines that check a pair of configuration jumpers (again, yielding a value between 0 and 3)
--- End quote ---
pinMode(x, INPUT) or pinMode(x, OUTPUT)
There are also existing keypad libraries.
The Arduino API only defines functions for reading/writing single bits; to replace code that reads multiple bits, you'll need to either convert the logic, assemble the multiple-bit fields from single bits, or step out of the Arduino APIs.
Navigation
[0] Message Index
[#] Next page
Go to full version