ZX-24n UART COM2 COM3 Problem.

Discussion specific to the 24-pin ZX microcontrollers, e.g. ZX-24r, ZX-24s and ZX-24t.
Post Reply
lhs860425
Posts: 1
Joined: 30 July 2012, 15:30 PM

ZX-24n UART COM2 COM3 Problem.

Post by lhs860425 »

I am trying to send out the data from the COM2 to a Wifi module(Wifly-RN131G).

The problem is when I try to send out a byte starting with a "1" in bit 7. It can't be sent out. For example "0xFF", "0xAA". If I send out "0xFF" 256 times, i will receive a wrong value 128 times.
But data like "0x0F", "0x7F" is OK. It's like it only sends out 7bits data instead of 8bits.

This is the setting of the COM
Call DefineCom(3, 14, 15, &H88, 1)
I am using the RS232 interface of the WiFi module so I enabled the inverted logic bit, bit7 of the the flag.

I also tried the COM2, connecting it to the TTL UART interface of the WiFi modlue
DefineCom(2, 0, 0, &H08, 1)
Same problem.

The UART setting of Wifi module is 8-N-1 and it's not configurable.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: ZX-24n UART COM2 COM3 Problem.

Post by dkinzer »

lhs860425 wrote:The problem is when I try to send out a byte starting with a "1" in bit 7.
How are you determining that incorrect data is being sent? If you're only looking at what the WiFi module reports receiving you may not be getting the whole picture. Instead, remove the WiFi module from the test and devise a way to confirm whether data is being sent correctly.

One way to do this is to send data from the ZX to a terminal emulator application running on your computer (TeraTerm is but one example of a free terminal emulator). Although TeraTerm cannot display the character codes of the received data, you can put it in "record" mode where it will write received data to a file. Then, you can use another application to examine the content of the file to see if it is correct. Many programmer's editors, for example, have the ability to display a file in hexadecimal mode. You could also use HexEdit or a hex dump utility like od that is part of many Unix tool kits.

Of course, to do this you'll need an RS-232 level converter to allow the ZX to be connected to your PC. If you don't have one available, you can build one using commonly available parts (you only need the transmit side). The ZBasic Language Reference Manual has several examples of RS-232 level conversion circuits.

Here is a test program that I used to confirm correct operation. Note, however, that the DefineCom() call is superfluous - the default is 8-N-1 mode.

Code: Select all

Dim oq(1 to 100) as Byte

Sub Main()
   Call OpenQueue(oq)
   Call DefineCom(2, 0, 0, &H08, 1)
   Call OpenCom(2, 19200, 0, oq)
   Do
      Call PutQueueStr(oq, Chr(&Hff) & Chr(&H80) & Chr(&H0d) & Chr(&H0a))
      Call Sleep(1.0)
   Loop
End Sub
- Don Kinzer
Post Reply