Help needed connecting the Next board UART to a PC RS232 serial port

This section is for discussing everything about Next hardware and latest updates.
User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Fri Dec 22, 2017 7:42 pm

Timbucus wrote:
Fri Dec 22, 2017 5:07 pm
You could connect the RX and TX to each other and then measure the voltage as you use the PC to set TX ON - as you say from the spec sheet it seems 3.6V is the max generated with Vcc at 3.3v - outbound from the Next would be perfectly safe to try anyway it would only be the data into it if it exceeded 3.3v (+/- tolerance) that could cause an issue. I will put it on the scope when I get time.
Cheers Timbucus.
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Mon Dec 25, 2017 7:18 pm

Here is a quick update. I finally decided to plug my serial port module into my TBBlue 2A board!!!

The good news is that it didn't blow up lol :)

The bad news is that I cannot get the UART to transmit anything from the Next to the PC. I've tried swapping Rx/Tx around but with no success.

In case you are wondering, I'm using an old PC command line tool of mine that works perfectly transmitting data between my ZX Spectrum +3 AUX port and my PC serial port using a NULL modem cable and a special converter. It's been working correctly for the last two weeks before I swapped it for the TBBlue 2A this afternoon. I've modified various parameters in the PC project to change the BAUD rate etc and it uses the 8N1 standard which the Next UART expects. I still have some more tests to try but I'm stumped as it should just work. Nothing comes through to the PC, no garbage, it just hangs waiting for the data to be ready. I'm monitoring BIT 0 of the Line Status Register (LSR). This method works fine when I've BIT-BASHED a BYTE from the +3 side at 57600 BAUD. I've tried as low as 19200 BAUD on the Next which it's built in UART should handle.

Here is an old picture of the +3 setup for reference:
PLUS3AUX.png
PLUS3AUX.png (559.63 KiB) Viewed 2091 times
The code to write to the ESP8266 port is a couple of lines of Z80. I'm using the OCP Assembler to build and run on the Next side of the project. I set the BAUD rate (0x143B) and OUT to the UART (0x133B). Have I missed a configuration register to enable the UART? Does the UART function in the mode I'm launching the OCP Assembler in from the NextOS browser (3.5MHz) ?

I'm wondering if the UART is working properly or enabled at firmware level at this moment in time?

My firmware is v1.03 / core v1.10 / OS v1.92B / 768K (1MB factory) (F3 toggles refresh) (VGA 700x575 @ 30KHz / 49.3Hz).
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Tue Dec 26, 2017 4:24 pm

Just a quick update, the reason why it didn't work is because I was using a NULL MODEM serial cable which crosses Rx/Tx. The module is already crossing Rx/Tx as it is connected using MALE DB9 to FEMALE DB9. I should have used a STRAIGHT THROUGH serial cable but as I don't have one I just plugged the module direct into my PC serial port and it worked first time sending a BYTE to the PC at 57600 BAUD!!!

The NULL MODEM cable was essentially used as an extender so the Next can sit on my desk!

Please excuse the box of tissues as it was something safe to place the board on :lol:
PC.png
PC.png (679.48 KiB) Viewed 2060 times
This is the joy of home computing Sir Clive and Lord Sugar gave us back in the 80s :) Now the real fun begins!!!
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Fri Dec 29, 2017 3:15 pm

Development of the RS232 serial download link has been a success. It works flawlessly at 115200 BAUD. My STRAIGHT THROUGH serial cable arrived along with my 1MB upgrade so the TBBlue 2A is back on my desk where it belongs :)

The Next job (no pun intended!) is to allow access to the full memory map and TBBlue 2A hardware completing my goal of creating a cross-development link for Next.

Cybernoid downloading in 5 seconds:
LINK_V05.PNG
LINK_V05.PNG (603.9 KiB) Viewed 2017 times
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
SevenFFF
Posts: 221
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by SevenFFF » Tue May 08, 2018 7:24 pm

Just found your thread, good stuff. Missed it at the time, as I didn't unpack my board until a couple of weeks later :D
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel Spectron 2084blog

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Tue May 08, 2018 7:36 pm

This seems so long ago now... I was worried at first about blowing up the board as they are hard to come by. I was always hearing stories of PDS killing Amigas and frying the comms chips of various other 8 and 16 bit machines. It all turned out well in the end. It's been awesome having cross-development on the Next - now with my own assembler too (NXASM).
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
fackie
Posts: 9
Joined: Thu Jun 08, 2017 5:47 pm
Location: Berkshire, UK
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by fackie » Fri Jan 18, 2019 10:05 pm

Thanks for your work @KevB, posting your steps so that we don't have to.

Now, I don't suppose you want to share your Next side serial routines for receiving the code and injecting into memory, do you? :-)

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Fri Jan 25, 2019 11:45 am

Hi, thanks for the interest in the serial code. My Next client is rather optimized for space. There is no stack and I use my own protocol but I have taken the core routines and edited them to be user friendly. You would need to add a time out to the code to make it more robust. Hope this helps :)

Code: Select all


; --------------------------------------------------------------------------


; SPECTRUM NEXT SERIAL LINK ROUTINES.

; **INTERRUPTS SHOULD BE OFF WHEN ACCESSING THE UART**

; see https://www.specnext.com/tbblue-io-port-system for register information.


RX	equ	143Bh
TX	equ	133Bh


; --------------------------------------------------------------------------


; **ADDITIONAL CODE WILL BE NEEDED TO SET OTHER BAUD RATES**

; A 14 bit prescaler value must be programmed into the the hardware to set up the BAUD rate.
; The BAUD rate must be adjusted for each video timing mode (VGA 0..6, HDMI 7).
; There are eight possible values for each rate.
; Register 0x11 (17) can be read to determine the 3 bit timing mode.
; This example assumes 115200 BAUD and videe timing mode 0 (VGA 0).

; 115200 BAUD timing modes 0-7, 14 bit prescaler values: 243,248,256,260,269,278,286,234


; Set timing for VGA 0 and 115200 BAUD.


init:	ld	bc,RX	; 115200 VGA mode 0 (243)  00000011110011
	ld	a,01110011b  ; Lower 7 bits of BAUD rate (LSB) 0LLLLLLL
	out	(c),a
	ld	a,10000001b  ; Upper 7 bits of BAUD rate (MSB) 1MMMMMMM
	out	(c),a
        ret


; --------------------------------------------------------------------------


; Empty the 512 BYTE FIFO.


flush:	ld	bc,RX     ; FIFO (Read 512 BYTES)
	xor	a,a

fifo:	in	d,(c)
	in	d,(c)
	dec	a
	jr	nz,fifo
	ret


; --------------------------------------------------------------------------


; Write data to UART.


; > HL = Source
; > DE = Length


out232:	ld	bc,TX

outb:	in	a,(c)
	and	a,2       ; TX busy?
	jr	nz,outb

	ld	a,(hl)    ; Read from memory
	inc	hl
	out	(c),a

	out	(254),a   ; Set border color

	dec	de
	ld	a,e
	or	a,d
	jr	nz,outb

	ret


; --------------------------------------------------------------------------


; Read data from UART.


; > HL = Destination
; > DE = Length


in232:	ld	bc,TX
	in	a,(c)
	and	a,1       ; RX busy?
	jr	z,in232

	ld	bc,RX
	in	a,(c)
	ld	(hl),a    ; Store to memory
	inc	hl

	out	(254),a   ; Set border color

	dec	de
	ld	a,e
	or	a,d
	jr	nz,in232

	ret


; --------------------------------------------------------------------------
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

User avatar
fackie
Posts: 9
Joined: Thu Jun 08, 2017 5:47 pm
Location: Berkshire, UK
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by fackie » Sat Jan 26, 2019 3:38 pm

Thanks for sharing @KevB - much appreciated.

User avatar
KevB
Posts: 57
Joined: Tue Dec 19, 2017 6:34 pm
Location: Yorkshire, United Kingdom
Contact:

Re: Help needed connecting the Next board UART to a PC RS232 serial port

Post by KevB » Sun Jan 27, 2019 2:16 pm

You are welcome, let me know if you get the UART working.
128K+, +2, +3, MF3, TBBlue 2A (2MB). ZX Spectrum fan since 1985. Next developer https://twitter.com/9bitcolor :: http://www.9bitcolor.com/

Post Reply