Using function on GR-KURUMI, Serial vol.
Let’s try hardware serial
GR-KURUMI CPU RL78/G13 has several hardware serials unlike Atmega32BP, in Arduino. GR-KURUMI support three serials (Serial, Serial1, Serial2). Let’s try to generate new project on web compiler or re-open project if you have built already.
Please refer to the code below for how to use each hardware serial.
The terminal number 0,1 on GR-KURUMI assigned for serial is used as the one for writing program, RXI, TXO. Can confirm output as it is on Tera Term after writing program into GR-KURUMI.
CPU Clock works at 8MHz on Arduino Pro Mini.In actual measurement, Arduino Pro Mini operate with baud rate up to 57,600bps.
CPU works at 32MHz clock on GR-KURUMI, expecting its baud rate is faster than Arduino Pro Mini.Here is the code for GR-KURUMI.
This program repeats “once receive, send it out.”
This program is called “loopback program”, useful to simply determine the normality/abnormality of the hardware devices on boards or cables.
On GR-KURUMI, you can set the faster baud rate than Arduino Pro Mini, without procedures such as flow control etc., some times the data will be missing while transmitting/receiving a large amount of data.
This possible data missing phenomenon should be taken into consideration on data transmission though we can’t say what seems to be a problem. ※Flow control has two methods, by software or hardware. Without judging receiving buffer status,it wouldn’t be implemented. Wishing flow control would be supported by library side.
Holding hands in a ring
With three serials, let’s try unique operation check.Please refer to the code below, pin layout on breadboard in the chart.Use jump wire or something for connecting No. 7 and 8, No. 9 and 10.
Buffer size adjustment
On serial communication, sometimes MCU treat the data as packet.When MCU transmit and receive a packet data of several hundred bite, if the buffer on serial has enough capacity, MCU can read/write it at a time, it would be more efficient on programming. While Arduino Pro Mini has only 2k bite of SRAM for buffer, GR-KURUMI has 10 times as much as Arduino.
Even ten times of SRAM size, GR-KURUMI has only 64kbyte library for buffer size in line with Arduino.The serial on GR-KURUMI wouldn’t generate buffer automatically when it generates instance, is already secured as the time of booting.
Please refer to「HardwareSerial.cpp」for the source code which influence buffer size.
Set the figure in the definition SERIAL_BUFFER_SIZE,you can adjust buffer size using for transmitting/ receiving the data.
I can’t believe.
if you change the figure in SERIAL_BUFFER_SIZE, everything (sending, receiving, serial, serial 1, serial 2) will change its size.
Everything is not necessary. If structure body ring_buffer consisted of buffer address, size, head and tail,it would solve problem by replacement with buffer and its size which was generated separately.
General hard engineer.. submitting his writing for technical magazine occasionally.