Switch off COM1 temporarily under software control? (ZX328L)

Discussion specific to the DIP and TQFP packaged ZX devices like the ZX-40, ZX-44, ZX-32 and ZX-328 series. The differences between these devices is primarily the packaging and pinout so most issues will apply to all devices.
Post Reply
kranenborg
Posts: 57
Joined: 27 July 2009, 14:20 PM
Location: Groningen, The Netherlands
Contact:

Switch off COM1 temporarily under software control? (ZX328L)

Post by kranenborg »

Hello,

On a ZX-328L I would like to experiment with the BusRead/BusWrite commands (bit banging version) for adding external static 32Kbx8 RAM. However this appears not really possible since none of the ports is fully "free" in that all 8 bits are user-configurable (Port C has only 6 pins, Port B includes crystal connections, and Port D includes the Com1 download interface).

Still I could imagine that it could be possible to "shut down" Com1 under software control, making it temporarily "deaf" to a download signal and thus making Port D fully available (which could be useful for other applications as well). Is there a possibility to do so ?

Best regards,
Jurjen
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Switch off COM1 temporarily under software control? (ZX3

Post by dkinzer »

kranenborg wrote:I could imagine that it could be possible to "shut down" Com1 under software control, making it temporarily "deaf" to a download signal and thus making Port D fully available [...]
You may be aware that Com1 cannot really be closed. If you invoke CloseCom() on channel 1 it doesn't really get closed. Rather it is closed and then automatically re-opened using the default parameters.

However, I believe that you can achieve the same effect by directly disabling the USART's transmit and receive sections. This can be accomplished by manipulating the USART control registers directly. The bits of interest are TXEN and RXEN in the UCSR0B register. Before setting those bits to zero, you should wait until a call to StatusCom() indicates that there is no more data to be transmitted or in the process of being transmitted.

Unless you've configured your ZX for an ATN character, disabling the USART will not make the ZX "temporarily deaf" because downloads are typically initiated by a special reset sequence.
- Don Kinzer
kranenborg
Posts: 57
Joined: 27 July 2009, 14:20 PM
Location: Groningen, The Netherlands
Contact:

Post by kranenborg »

Thanks Don, that is exactly what I hoped for because this adds quite a bit on a ZX-328. Two bits - and a full port - really count on a small device, and now the BusRead/BusWrite/DefineBus commands can be applied as well.

Maybe it would be an idea to add Connect / Disconnect commands to the library for (re)setting the corresponding USART bits?

I assume that changing the fuse settings for the reset pin (to gain one extra port pin, namely C.6) will be impossible for a program, for it is a fuse, literally ..

/Jurjen
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

kranenborg wrote:I assume that changing the fuse settings for the reset pin (to gain one extra port pin, namely C.6) will be impossible for a program, for it is a fuse, literally ..
Yes, it cannot be changed programmatically. Even if that were possible it would be inadvisable because reset is required as part of the download protocol.
- Don Kinzer
kranenborg
Posts: 57
Joined: 27 July 2009, 14:20 PM
Location: Groningen, The Netherlands
Contact:

Post by kranenborg »

I checked the situation with the Oak Micro ZX-328nu and note that the approach as discussed here should definitely not be applied to that device since the Tx and RX pins of the uC are directly connected to the on-board USB chip.

/Jurjen
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

kranenborg wrote:I checked the situation with the Oak Micro ZX-328nu and note that the approach as discussed here should definitely not be applied to that device since the Tx and RX pins of the uC are directly connected to the on-board USB chip.
I agree :)

But then again I wouldn't stretch such a small device. If I wanted some additional RAM for my ZBasic device I would buy something like the ZX-128ne which supports up to 64K RAM with zero wait states (i.e. isn't slow compared to big-banging to RAM yourself).
Mike Perks
Post Reply