Hi all, i have tried to do digital data acquisition from xilinx ic and send the acquire data from 8051 to pc, it does not show anything. I have tried to display the acquired data on LCD and it works fine ie the 8051 able to acquire data from xilinx ic. but when transmit to serial comm rs232 no display happen. I have debug the program it display the output. Basically, the progrm is to acquire data by writing channel add at P1 (of 8051) , get the data from PA & PB of 8255 and later on transmit to pc via rs232. Here is my code :
#include <stdio.h> #include <math.h> #include <reg51.h> /*Declaration of 8255 port*/ xdata unsigned char PA = 0x4000; //PORT A used as Data input LSB from Freq Counter Xilinx xdata unsigned char PB = 0x4001; //PORT B used as Data input MSB from Freq Counter Xilinx xdata unsigned char config = 0x4003; /* Configures the PPI :PA & PB as input, PC as output */ void ppi_set() { config = 146; } /*Function to initialize RS232 serial port*/ void serial_init() { SCON=0X50; //Setup for 8-bit data TMOD=0X20; //Setup Timer 1 for auto-reload TH1=0XFD; //Setup for 9600 baud TR1=1; //Turn on Timer 1 TI=1; //Indicate Ready to Transmit } /*Wait state*/ /*void wait(unsigned int time) { int i; for (i = 0; i < time ;i++){ } } /*Main Program*/ main() { int CH[10],data_LSB,data_MSB,pmax=10,n=8,i,j,min=10000,max=0; float CHn[10]; ppi_set(); serial_init(); for (i=0;i<=pmax;i++) //for number of pulse <=10 { printf("\n\nDAQ: %d",i+1); printf("\n8 Channel Raw Data\n"); for (j=0;j<n;j++) //If yes do DAQ of 8 Ch (0-7) { P1=j; //Write Add to Port 1 (0-7) wait(10000); //wait for 100ms data_LSB=PA; //Read LSB data from Port A data_MSB=PB; //Read MSB data from Port B CH[j]=(data_MSB<<8)|data_LSB; //Shift Left MSB data 8 times ("|"is bitwise 'or' to sum both bit) printf("CH[%d]= %d\n",j+1,CH[j]); //Transmit Data to PC ?? not sure correct or not min=(min<CH[j])? min:CH[j]; //Scan for Min data max=(max>CH[j])? max:CH[j]; //Scan for Max data } printf("\n"); printf("8 Channel Normalized Data\n",i+1); for (j=0;j<n;++j) { CHn[j]=2*((CH[j]-min)/(max-min))-1; //Data Normalization formula make data in range (-1,1) printf("CHn[%d]= %f\n",j+1,CHn[j]); } } } Is there anything wrong with this code? Your help is much appreciated. thanks