Hello I need help for commands in obtaining data from Serial port of Z8 Encore

Status
Not open for further replies.

xueyuanlu

New Member
Hello, I am trying to interface a temperature sensor to the UART of Z8 Encore.
My problem is, how do I code it, I mean what command should I use in order to get data from the UART?

A simple diagram of my project is like this:


TEMPERATURE SENSOR (Tx Pin) --> Z8 Encore (Rx Pin)
and common ground.

I am also wondering. I am quite new in the world of microcontrollers, and I bought the sensor along with the Z8 Encore. The one who sold me the sensor told that in order to connect the Sensor to Z8, just tap the Sensor's T'X Pin to the Z8 Encore's R'x Pin, and their common ground. Is it possible to have only two connections in UART?


Also, how to get data from UART
I use this command:

ch = getch();?

However, the it does not respond as expected, in a way that no response at all. I know that in serial communications, it consist of 8 data bits, I'm thinking if the getch command would suffice here.

In summary here are my questions:

1. Is it alright to have only two pin connections in RS232 communications or the one who sold me the materials are just telling me fake? (T'x Pin of Sensor to R'x Pin of Z8 Encore and their common ground)

2. If the first question is possible, how do I get data from the sensor? I used getch() but it does not work.

Thanks to those who will answer.
 
1. Yes, one way with common ground is fine.
2. If you are using C, the simplest answer here is that you need to init the hardware UART and start interrupt processing before the default getch() and putch() functions work.

Code:
#include<ez8.h>
#include<sio.h>
init_uart(_UART0,_DEFFREQ,19200); // set-up UART 0
EI();                                 // Enables the interrupt globally.

//then you can do your
char = getch();

Unfortunately it looks like you're starting from ground zero here. You might want to try the Z8 Encore! yahoogroups mailing list if you need any more help.

**broken link removed**
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…