I am trying to communicate a microcontroller P89c51RD through serial port with a analog input(AI) module ICP_DAS. The AI has an own communication protocol, (send #011 and it responds to channel 1, i.e +0.065), using other languages (LabView) I have not had any problem to read the analog input. I have made sure that the configuration of the port is correct, that the format of the sent data is adapted (string). But I do not know that it happens, because microcontroller does not receive anything. Part of my code is this:
// Function to send command to read analog input. bit lee_AI_ICP(void) { bit send; char lee_ai[10]="#011"; printf("%s\r", lee_ai); send=0; return send; } // Part of main routine while(1) { if (send&&buffer_full) { send=lee_AI_ICP(); buffer_full=0; } if (RI&&(!buffer_full)) { medida[buf_cnt]=_getkey(); buf_cnt=++buf_cnt; RI=0; } if (buf_cnt==6) { buffer_full=1; buf_cnt=0; send=1; } }