MEL PICBASIC Forum - How to calculate the MODE number for SERIN2/SEROUT2

• ### Recent Forum Posts

#### Re: Nextion LCDs... How to comunicate ???

Starting on Page 16:
...

mpgmike Today, 02:15

#### Re: Nextion LCDs... How to comunicate ???

Mike's tutorial on Nuts n Volts is good starting point.

Also the tutorials on YouTube are very helpful. There are many that take you step by step.

Ioannis

Ioannis Yesterday, 21:35

#### Re: Nextion LCDs... How to comunicate ???

I also ordered a module, waiting for delivery. Meanwhile, I've downloaded their IDE. Looks like Visual Studio, but so far, I have not managed, how to put my own text on label :D Very alogical...

CuriousOne Yesterday, 20:17

#### Re: 3 digit 7-Seg serial Display

[QUOTE=Ioannis;144615]Not clear what you mean.

Ioannis,

I'm missing the minutes on the first LED dsp... :o

Gevo - 14th January 2020, 16:18
• # How to calculate the MODE number for SERIN2/SEROUT2

How to calculate the MODE number for SERIN2/SEROUT2.

This information is in the manual and appendix "A" in the manual has many of the MODE numbers listed, but sometimes a different explanation is helpful.

First, the MODE number is a 16 bit binary number represented in decimal form. Inside this number is all of the information needed to set the baud rate, none or even parity, inverted or true, and open or driven.

The first 12 bits set the baud rate. This is found by the equation:
(1,000,000 / baud) - 20

Example to find the MODE number for 4,800 baud, 8 data bits, No parity, and 1 stop bit. (8N1)
(1,000,000 / 4800) - 20 = 188
Convert 188 to binary for the first 12 bits
_ _ _ _ _ _ _ _ 1 0 1 1 1 1 0 0

Bit 13 will be 0 for No parity.
_ _ 0 _ _ _ _ _ 1 0 1 1 1 1 0 0

Bit 14 will be set to 1 so we can connect directly to a PC with out an inverter circuit of inverter chip.
_ 1 0 _ _ _ _ _ 1 0 1 1 1 1 0 0

Bit 15 is set to 0 for Driven.
0 1 0 _ _ _ _ _ 1 0 1 1 1 1 0 0

Fill in the blanks.
0100000010111100 and convert to decimal
and we have the MODE number of 16572.

To have 4,800 baud inverted and change the parity to Even giving 7E1 simply change bit 13 from 0 to 1.
0 1 1 _ _ _ _ _ 1 0 1 1 1 1 0 0
0110000010111100 and convert to decimal
and we have the MODE number of 24764.

For information about converting from one number system to another you can go here.
http://melabs.com/resources/articles/index.htm