Gamit ko yung IRC Slimboard na may Z8F6421 and yung AC Power Analyzer Kit ng e-Gizmo. Connected na silang dalawa using UART. Now, yung AC Power Analyzer Kit is supposed to send a string to the MCU. My problem is, pano ko makukuha yung data na yun at mai-manipulat4e sa program?
Nag-search ako sa internet, dito sa forums, at pati sa CD na kasama nung mga kits. Ito lang ang nakuha ko:
/******************** Hello World! *********************/
/* This program displays text on the HyperTerminal and */
/* makes the LEDs connected to PA0 and PA1 blink. */
#include <ez8.h>
#include <stdio.h>
#include <sio.h>
#define GPIO_PORT 0x02
void initGPIO(void){
PADD &= ~GPIO_PORT; // data direction: output
PAAF &= ~GPIO_PORT; // alternate function: off
}
void delay(void){
unsigned char i,j;
for(i = 0; i < 0xFF; i++)
for(j = 0; j < 0xFF; j++);
}
int main(void){
init_uart(_UART1, _DEFFREQ, _DEFBAUD);
initGPIO();
// printf("Hello World\n");
while(1){
if (!(PBIN & 0x01)){
printf("tumutunog\n");
PAOUT |= GPIO_PORT;
delay();
delay();
delay();
}
else {
printf("tahimik\n");
PAOUT &= ~GPIO_PORT;
}
}
}
Yung pinakamalapit na nakuha is yung:
init_uart(_UART1, _DEFFREQ, _DEFBAUD);at yung:
select_port(_UART0);kaso, if i'm correct, initialization lang ng UART yun.
Pano ako makaka-receive ng data from the UART gamit yung IRC slimboard?