Hello,
The display uOLED-96 Tx and Rx is connected to my microcontroller.
The display Rx is works fine, and what i'm sending from the microcontroller is what is see on the display.
but something is wrong on the Tx (to the microcontroller), i cannot read correctly the serout.
I'm sending '5' using "serout" syntax and got '.' or A or B in the microcontroller.
I'v tried several buffer sizes.
What can be the problem?
The code:
-------------------------
#platform "GOLDELOX" /* 4DGL Demo Application - Test Serial Echo - -- GOLDELOX Platform --*/ #inherit "4DGL_16bitColours.fnc" var combuf[24]; // 24 vars = 48 bytesvar combuffer[1]; // 24 vars = 48 bytes func main()var chr,char, e, e2; e := 0; e2 := 0; repeat gfx_Set(OUTLINE_COLOUR, DARKOLIVEGREEN); // set outline colour, gfx_Cls() will draw outline gfx_Cls(); txt_Set(FONT_ID, 0); txt_MoveCursor(0,1); // reset cursor to line 1, column 2 putstr("Serial Echo\n9600 baud"); setbaud(BAUD_9600); // 9600 baud comms com_Init(combuf, 48, 0); // set up a comms circular buffer, use the entire buffer, no sync character repeat pokeW(TIMER0, 5000); // set delay so we stay in next loop for 5 seconds // wait for a while gathering bytes // and continuously displaying the count // of characters in the buffer. repeat txt_MoveCursor(2,1); // reset cursor to line 3, column 2 print("Buffered ", [DEC2Z] ( com_Count() )); // show count of chars in buffer until (!peekW(TIMER0)); // loop until TIME_OUT register is 0 if (com_Full()) txt_MoveCursor(3,1); // reset cursor to line 5, column 2 print("Buffer Full ", (++e) ); // print error count endif if (com_Error()) txt_MoveCursor(4,1); // reset cursor to line 7, column 2 print("Comms Error ", (++e2) ); // print error count endif // now dump whatever we got to the terminal while ( (char := serin()) >= 0) txt_Set(TEXT_COLOUR, RED); gfx_MoveTo(20,44); print("\n'",[CHR]char,"' is "); to(COM0); putch(char); // send buffered chars to com port //wend gfx_MoveTo(10,44); switch case (char == '3') putstr(" THREE"); com_Init(combuffer, 2, 0); // reset buffer serout('5');//to(COM0); putch('5'); // break; case (char == '2') putstr(" TWO"); default: //putstr(" Idle"); endswitch wend pause(1000); until ( com_Full() || com_Error() ); // reset if error occurred forever endfunc
The display uOLED-96 Tx and Rx is connected to my microcontroller.
The display Rx is works fine, and what i'm sending from the microcontroller is what is see on the display.
but something is wrong on the Tx (to the microcontroller), i cannot read correctly the serout.
I'm sending '5' using "serout" syntax and got '.' or A or B in the microcontroller.
I'v tried several buffer sizes.
What can be the problem?
The code:
-------------------------
#platform "GOLDELOX" /* 4DGL Demo Application - Test Serial Echo - -- GOLDELOX Platform --*/ #inherit "4DGL_16bitColours.fnc" var combuf[24]; // 24 vars = 48 bytesvar combuffer[1]; // 24 vars = 48 bytes func main()var chr,char, e, e2; e := 0; e2 := 0; repeat gfx_Set(OUTLINE_COLOUR, DARKOLIVEGREEN); // set outline colour, gfx_Cls() will draw outline gfx_Cls(); txt_Set(FONT_ID, 0); txt_MoveCursor(0,1); // reset cursor to line 1, column 2 putstr("Serial Echo\n9600 baud"); setbaud(BAUD_9600); // 9600 baud comms com_Init(combuf, 48, 0); // set up a comms circular buffer, use the entire buffer, no sync character repeat pokeW(TIMER0, 5000); // set delay so we stay in next loop for 5 seconds // wait for a while gathering bytes // and continuously displaying the count // of characters in the buffer. repeat txt_MoveCursor(2,1); // reset cursor to line 3, column 2 print("Buffered ", [DEC2Z] ( com_Count() )); // show count of chars in buffer until (!peekW(TIMER0)); // loop until TIME_OUT register is 0 if (com_Full()) txt_MoveCursor(3,1); // reset cursor to line 5, column 2 print("Buffer Full ", (++e) ); // print error count endif if (com_Error()) txt_MoveCursor(4,1); // reset cursor to line 7, column 2 print("Comms Error ", (++e2) ); // print error count endif // now dump whatever we got to the terminal while ( (char := serin()) >= 0) txt_Set(TEXT_COLOUR, RED); gfx_MoveTo(20,44); print("\n'",[CHR]char,"' is "); to(COM0); putch(char); // send buffered chars to com port //wend gfx_MoveTo(10,44); switch case (char == '3') putstr(" THREE"); com_Init(combuffer, 2, 0); // reset buffer serout('5');//to(COM0); putch('5'); // break; case (char == '2') putstr(" TWO"); default: //putstr(" Idle"); endswitch wend pause(1000); until ( com_Full() || com_Error() ); // reset if error occurred forever endfunc
Comment