Blue in the face... maybe should be red...

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
jay
Posts: 37
Joined: 08 July 2006, 13:58 PM
Location: Vermont, USA

Blue in the face... maybe should be red...

Post by jay »

I've looked and looked and can't see what I'm doing wrong.

Code: Select all

Const redLED as Byte = 25
Const grnLED as Byte = 26
Const rxPin As Byte = 7
Const txPin As Byte = 8

Const ComPort As Byte = 3
Dim iQ3(1 to 40) as Byte
Dim oQ3(1 to 40) as Byte

Sub Main()

	' Turn LED off
	
	Call PutPin(redLED, zxOutputHigh)
	Call PutPin(grnLED, zxOutputHigh)
	
	Call OpenQueue(iQ3, SizeOf(iQ3))
	Call OpenQueue(oQ3, SizeOf(oQ3))
	
	Call DefineCom(ComPort, rxPin, txPin, &H08)
	
	Call OpenCom(ComPort, 19200, iQ3, oQ3)
	
	 
	Do
		Call PutQueueStr(oQ3, "RED")
		Call PutPin(redLED, zxOutputLow)
		Call Delay(0.5)
		Call PutPin(redLED, zxOutputHigh)
		
		Call PutQueueStr(oQ3, "Green")
		Call PutPin(grnLED, zxOutputLow)
		Call Delay(0.5)
		Call PutPin(grnLED, zxoutputHigh)
	Loop
End Sub	

If I move the receive from pin1 to pin 7, I get
«×£SÓ«×£SÓ
on the debug console. BTW, if I use Com1 and pin 1 I get the correct data..
This seems so simple... I'm running 1.3vm and 1.3.2 ide
..tks Jay
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Blue in the face... maybe should be red...

Post by dkinzer »

jay wrote:If I move the receive from pin1 to pin 7[...]
I'm not sure what you mean by this. Pin 1 is not a valid pin number to use for any operations on the ZX-24. The set of valid pin numbers is 5-20, 25, 26 and 27.

Secondly, to connect a ZX serial port (other than Com1) to a PC or other serial device you may need to use a level converter. Standard RS-232 signals have a logic 0 represented by a voltage between +3 and +12 while a logic 1 is represented by a voltage between -3 and -12. Many devices, including most PC ports, will interpret a voltage near ground as a logic 1. Applying an RS-232 signal directly to a ZX-24 (other than connection to Com1) may damage it.

You may be able to use some standard inverters to do the level conversion. Another option is to use a conversion chip like the MAX232 or similar. Examples of conversion circuits are shown in the ZBasic Reference manual appendix section ZX-40 Suggested Circuits. Although these circuits are suggested for use with Com1, they will work equally well with Com3 to Com6.

Note that some serial devices that you might want to connect to a ZX (e.g. an LCD) may provide TTL-level serial signals. In this case, the interface may require inverted levels or it may require non-inverted levels. The software serial ports (Com3 to Com6) can be configured to use either mode so direct interfacing to such devices is possible.

This information may not be sufficient to resolve your problem. If not, please post more details.
- Don Kinzer
jay
Posts: 37
Joined: 08 July 2006, 13:58 PM
Location: Vermont, USA

Post by jay »

Don.. thanks.. it is obvious.. I didn't use a level shifter .. may have damaged the ZX-24.. I was not thinking. I was planning on using com3 to connect to a 75176 (ttl/rs485), but decided to write some simple test code first.. and my brain shut down. Sorry for the interruption, but appreciate your time.

BTW, in my first note, I was referring to the serial out pin on the ZX-24 as 'pin1' ..

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

Post by dkinzer »

jay wrote:I didn't use a level shifter .. may have damaged the ZX-24
All of the inputs to the CPU have protection diodes connected as shown in the image below. If you connect a limiting resistor as shown, the processor will better tolerate negative voltages and voltages higher than +5. The size of the limiting resistor depends on what you have connected to the I/O pin but something in the range of 330 ohms to 1K ohm may serve the purpose.

Some people recommend using a limiting resistor as a matter of course as protection against incorrect wiring and other suprises that Murphy always has at the ready.
Attachments
IO_protection.jpg
IO_protection.jpg (8.47 KiB) Viewed 7157 times
- Don Kinzer
jay
Posts: 37
Joined: 08 July 2006, 13:58 PM
Location: Vermont, USA

Post by jay »

Thanks for the tip. I'll use some limiting resistors on my breadboard from now on.

Jay
Post Reply