The states of both the buttons and the switches are stored at address 0FFFFFFC4H (decimal -60) as documented in Chapter 17
The processor's environment of the Project Oberon book. You can access this from the Astrobe > Help > Project Oberon menu.
The switches are represented by bits 7..0 and the buttons by bits 15..8.
e.g. if switches 0 and 2 are on then bits 0 and 2 are set. If button 0 is pressed then bit 8 is set etc. You can use the built-in Oberon functions SYSTEM.GET and SYSTEM.BIT to access words, bytes and individual bits at specific addresses. Example source code for both is included in the
latest release of Astrobe for RISC5. However, I recommend that you try to write a simple example yourself first and only look at the examples if you get really stuck.
Once you have understood how switches and buttons can be programmed you should be ready to tackle GPIO. Here are some hints to get you started:
Code: Select all
GPIOAddr = -32;
GPIOControlAddr = -28;
SYSTEM.PUT(GPIOControlAddr, {bitNo}); (* Set bitNo to be an output *)
SYSTEM.PUT(GPIOAddr, {bitNo}); (* Set bitNo *)
As for ADC I believe you'll have to write some Verilog code to access the ADC features on the Arty board. Have a look at the Arty XADC demo on Digilent's website. However, if your Verilog skills are limited you might be better off investigating Digilent's
Pmod AD5: 4-channel 4.8 kHz 24-bit A/D Converter as it has an SPI interface. The
SPI code example we wrote for the SparkFun Real-time Clock breakout board should be a useful starting point to get it working.