Small ZX devices: switching off COM1 -> freeing port D

Here you can share completed projects or parts of projects that may be useful to others. You may post files relevant to ZBasic - source code, schematics, etc.
Post Reply
kranenborg
Posts: 57
Joined: 27 July 2009, 14:20 PM
Location: Groningen, The Netherlands
Contact:

Small ZX devices: switching off COM1 -> freeing port D

Post by kranenborg »

The following small code example shows how all 8 bits of Port D can be made available for I/O by switching off the hardware UART for COM1. The latter operation makes D.0 and D.1 accessible to standard I/O operations via Register.PortD (although the compiler blocks PutPin operations on these two pins). This may be relevant for the smaller ZX variants where a full port is not always available, or for larger variants where a combination of I2C and ADC use excludes a fully available port as well.

The code is an outcome of the following discussion : http://www.zbasic.net/forum/about1278.html. The example in the attachment describes the use of a common-anode 7-segment display on port D. The code includes a description of the test hardware.

Jurjen Kranenborg
Attachments
SevenSegmentTest.zip
(1.12 KiB) Downloaded 2112 times
Last edited by kranenborg on 07 August 2019, 7:38 AM, edited 2 times in total.
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

This code can only be used for native devices I believe. The code should have the following around it

Code: Select all

#if Option.TargetCode="ZVM"
#error Unsupported device
#else
<< code goes here >>
#endif
Mike Perks
Post Reply