MIME-Version: 1.0 Content-Location: file:///C:/A13C5D12/8051SingleBoardComputer.htm Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset="us-ascii" 8051 Single Board Computer

80= 51SBC V1.0

New Microprocessor learning board demonstrates exemplary des= ign of 8-bit single board computer.  More peripheral and easy to adapt to = be a dedicated controller.



I decided to rename C52E= VB to be 8051SBC. Since the cpu can be any 8051 compatible chips with 40-pin DIP package. The old day chips, say 8031, 8751, 8032 or the new chips, 89C51, 89C52, 89C51RD2 can be used without any problem. Some may think that your o= ld chips were useless, now you can use it for many projects. The monitor progr= am of new 8051SBC was placed at external 32kB EPROM. With this space, you can customize your own monitor code or even add the application program and have the DIP switch to boot it when power up. The 32kB SRAM still be mapped as external code and data memory. We can test the program in RAM, when it firms then put it in the space in EPROM. The memory and i/o decoder is now using = GAL (Generic Array Logic).

Figure 1: The prototype of 8051SBC (click = for big picture).

The hardware schemati= c was provided to be an exemplary design for student to learn basic design of 8-b= it microprocessor board. The board is a generic tool for every microprocessor = lab. I provided all materials in public domain, so you may build it for your lab. Student can learn assembly programming, HLL programming and hardware interfacing.

The new 8051SBC featu= res;

Hardware Schematic

Complete schematic fo= r cpu and memory is shown in Figure 2. U7 is 40-pin 8051 compatible chip. The xta= l is 11.0592MHz. JP1 selects internal or external code memory. With the external monitor mode, we make EA# to GND. The data bus D0-D7 are tied to memory chi= p, U1, U2 and to the GPIO, U3, U4 directly. Both memory chips are 32kB, so each chip needs A0-A14. A15 is used for memory decoder that decodes between first 32kB and second 32kB of external code memory. When A15 =3D 0, U1 the monito= r rom was selected. The OE# of U1 is tied to PSEN#, so the code memory will enable only when address range 0x0000-0x7FFF of code memory are accessed. The upper memory space from address 0x8000-0xFFFF makes A15 =3D 1. When A15 =3D 1, U2= or SRAM will be selected. This memory space was decoded to be overlapped between external data and code memory. So while running under monitor mode, we can = then load the hex code into the SRAM(data memory) and when JUMP from monitor pro= gram to address says 0x8000, the PSEN# that AND with RD# and ties to OE# of SRAM will enable the RAM to be code memory.

Since we have decoded= the lower space, 0x0000-0x1FFF for code memory, this left a big space for exter= nal data memory from 0x0000-0x1FFF. The 8051SBC then borrowed this area to make= the I/O that can access as the memory space with RD# and WR# combination with address decoder.

We can say that this = area is memory mapped I/O. U3 is an 8-bit D-FF for output port. U4 is 8-bit tris= tate for input port. The LCD also connects cpu bus directly. To make the I/O dec= oder for each chip, we use A8, A9, A10 and A15 to select each block. The I/O map shows the address range for each device. U6 is PLD made from GAL16V8. It provides the memory and I/O decoder, later you will see details description= on how to implement the decoder.

Figure 2: Complete hardware schematic, CPU, memory, PLD

Figure 3: RS232, RS485, DC supply, EEPROM, ADC, RTC, keypad, debug LED.

U8 is +5V voltage regulator. D4 is protection diode. The RS232 level converter is MAX232. Not= ice that we have the RS485 transceiver as well. The TxD pin from CPU can tie to both input, T1IN (U10) and D(U12) directly. Howvere the RxD pin is the outp= ut of AND logic between R1OUT(U10) and R(U12).  U11 is 32kB I2C EEPROM. It uses for program storage or the aplliaction program can use it. U9 is a pop= ular 12-bit ADC having SPI interface. The reference voltage uses +5V. The two channels analog input has RC filter. U13 is RTC with I2C interface. It shar= es the I2C signal with EEPROM, U11. SW1 is 4-bit DIP swicth for system setting= s. User can use S3, S4, S5 and S6 for application program.

CPU = list

I have tested some of 40-pin DIP package 8051 compatible CPU with the 8051SBC, table 1 shows the reason for each chip and you may find the right for your applications.
 

8= 751

o= ld chip with ceramic package and quartz window for UV, new generation will see how the old chip look likes.

8= 031

r= omless 8051, 128 bytes RAM

8= 032

r= omless 8051, 256 bytes RAM

8= 052

b= asic interpreter with EA =3D +VDD

A= T89S8252

S= PI, WDT, 2kB EEPROM, 8kB FLASH, 256 bytes RAM

A= T89C51

4= kB FLASH 128 bytes RAM

A= T89C52

8= kB FLASH 256 bytes RAM

D= ALLAS DS500T

8= kB loadable RAM RTC

Table 1: CPU tha= t can be used with 8051SBC.

GAL Decoder

The reason that took = me to use GAL is to reduce the number of discrete gate for memory and i/o decoder. You may noticed that, with a C52EVB, only one chip, the 74HC00 was used for memory and 8255 decoder. However with new 8051SBC, I need to decode the LCD= and simple port. This needs more chip, so better try with 20-pin popular GAL fr= om Lattice, the GAL16V8D. The GAL can emulate logic function and can reprogram many times.

Before getting into G= AL's matter, let begin with how to replace the logic gate using logic equation. = Now let see the actual decoder circuit. First take a look for memory decoder.

The EPROM will place = at 0x0000 to 0x7FFF. And the SRAM will place at 0x8000 to 0xFFFF. We see that = we can use A15 to be a chip select control signal for EPROM directly. Whereas = for the SRAM it needs to invert A15 in order to select SRAM when A15 becomes '1' for address 0x8000-0xFFFF.

Not= e * is active low signal.

To read or fetch the content of EPROM, the place we store monitor program, we must provide *PSEN signal tied to output enable pin.

However for SRAM, we = will use it for user program running as well as the place where we can edit the machine code, so we must make it to be code and data memory space. This can= be made easily with *RD and *PSEN logical AND together. The circuit would be,<= /span>

A b= it complicate for i/o decoder, as shown below we see the popular decoder chip,= the 74LS138, 3-to-8 line decoder and some gates were used to provide control si= gnal for the i/o devices. The i/o space uses the external data memory with addre= ss 0x0000 to 0x7FFF. A15 must be low to enable the output of 74LS138. A8-A10 selects the active low output for each i/o.

Let look at the first device, the LCD. Y0 will active low when all inputs are low, or A8-A10 and = A15 =3D '0'. The datasheet of LCD says, the signal E of LCD will active for bot= h read or write cycle, so we AND them together with U5B. U6B provides the positive pulse when Y0 and pin 6 of U5B low. This signal, LCD_E can then directly ti= e to signal E of the LCD.

Similarly for GPIO1 or 74HC573, latch signal. Now GPIO1 uses Y1, that means A8 must be '1', A9,A10= and A15 must be '0'. The WR signal is logical OR with Y1. The NOR gate U7B prov= ides the positive pulse similar to the LCD_E signal. This signal will control th= e D FF latch. Dada is loaded into FF and the is latched at high to low transiti= on.

For the input port ma= de by tri-state buffer, 74LS244, the enable signal was made by Y2 and RD signal. However now A9 must be '1' and A8, A10 and A15 must be '0'.

With above decoder, w= e then need more chips to make it. Now let see how the GAL chip looks like.=

GAL1= 6V8D

  The GAL chip was Lattice GAL16V8D. The GAL is a programmable logic device (PLD). We can write the lo= gic equation, convert it to JED file and program the GAL with JED file. Then we= can replace above circuit with single GAL chip. The GAL16V8 has 10 inputs and 8 outputs. The chip can reprogram many times. In this design I used only one = chip to replace such memory and i/o decoder circuit.

Usin= g PLD Assembler

To implement the logi= c with GAL, we must first edit the logic equation and have the PLD assembler to translate the equation file to JEDEC file. I found OPALjr 2.0= from google search. It's very easy to use. Now let see the equation of above decoder.
 

;= 8051SBC PLD Equation
; Memory and I/O decod= er for 8051 Single Board Computer
; Wichit Sirichote, kswichit@kmitl.ac.th
; May 1, 2003 <= br> ; PLD: Lattice GAL16V8= D

CHIP 8051SBC GAL16V= 8

 a15=3D1 rd=3D= 2 wr=3D3 a8=3D4 a9=3D5 a10=3D6 rs232=3D7 rs485=3D8 psen=3D9 rom_ce=3D12
 ram_ce=3D13 ram_= oe=3D14 rom_oe=3D15 lcd_e=3D16 gpio1=3D17 gpio2=3D18 rxd=3D19

EQUATIONS

ram_oe =3D rd * pse= n

rxd =3D rs232 * rs4= 85

rom_ce =3D a15

ram_ce =3D /a15

rom_oe =3D psen

/lcd_e =3D rd * wr = + a8 + a9 + a10 + a15

/gpio1 =3D /a8 + a9= + a10 + a15 + wr

gpio2 =3D a8 + /a9 = + a10 + a15 + rd 

Note. * is logical AN= D, + is logical OR and / is logical NOT.

There is some i/o pin available on GAL, I also used them for sharing between rs232 and rs485. The output is tie to RxD pin of the cpu. See schematic for detail.

When finish editing t= he equation file, click MODULE -> EQU2JED, it will convert the equation fil= e to JEDEC file. Let look at the output JEDEC file.
 

GAL16V8
EQN2JED - Boolean Equations to JEDEC file assembler (Version V101)
Copyright (c) National Semiconductor Corporation 1990-1993
Assembled from "D:\C52EVBV3\O\8051SBC.EQN". Date: 5-1-103
*
NOTE PINS a15:1 rd:2 wr:3 a8:4 a9:5 a10:6 rs232:7 rs485:8 psen:9*
NOTE PINS rom_ce:12 ram_ce:13 ram_oe:14 rom_oe:15 lcd_e:16 gpio1:17*
NOTE PINS gpio2:18 rxd:19*
NOTE GALMODE SMALL*
QF2194*QP20*F0*
L0000
11111111111111111111011101111111*
L0256
11111111011111111111111111111111
11111111111110111111111111111111
11111111111111110111111111111111
11011111111111111111111111111111
01111111111111111111111111111111*
L0512
11111111101111111111111111111111
11111111111101111111111111111111
11111111111111110111111111111111
11011111111111111111111111111111
11110111111111111111111111111111*
L0768
01110111111111111111111111111111
11111111011111111111111111111111
11111111111101111111111111111111
11111111111111110111111111111111
11011111111111111111111111111111*
L1024
11111111111111111111111111110111*
L1280
01111111111111111111111111110111*
L1536
11101111111111111111111111111111*
L1792
11011111111111111111111111111111*
L2048
11001111*
L2128
1000000011111000111110001111100010000000100000001000000010000000*
L2192
10*
C5053*
0000

The JEDEC file is sta= ndard file for any GAL programmer. I used = GALBLAST to program it.

Before you can use GA= L or any PLD efficiently, you must have knowledge on the fundamental of digital logic. The PLD is just to help hardware design more easy.

12-b= it ADC converter

I found Microchip 12-= bit ADC converter, MCP3202 that can replace Linear Technology LTC1298 directly. Below is pin diagram of 8-pin DIP package. MCP3202 is cheaper than LTC1298. Both chips are pins compatible. The 8051SBC can use either one without any problem.

Soft= ware

With the external 32kB EPROM, the 27C256, we then need the EPROM programmer. I used willem EPROM programmer. Also here = in Thailand http://se-ed.net/mpu51/= You may build it easily. Later I'll add the EPROM programmer attach to the 8051= SBC.

The main monitor code= space is approx. 8kB. This fits exactly in 89C52 chip. So you can add many things into 32kB EPROM. During firmware developing, I used parallel eeprom, 28C256 from ATMEL. I made the adapter from two sockets. The socket swaps pin 1 and= pin 14. If you have the 28C256, you can use my idea.

Some may got many cer= amic EPROM, 27C256. To erase it, you need Ultraviolet light. When your code firm= s, you can write the program into a cheap 27C256 OTP (One Time Program).

The monitor program composes of three files.

1. 8051SBC= .ASM
2. myextra= 1.ASM
3. new.c<= /span>

The 8051SBC.ASM and myextra1.asm are modified version of PAULMON2 free monitor program written = by Paul Stoffregen. Both files fit in 8kB space. The new commands is now under developing with Micro-C compiler. The available for download was tested on = RAM and then recompile with MEDIUM memory model. In addition to such monitor co= de, I also experimented with Camel FORTH. EEPROM booting still working with this version excepts the boot switch is now move to DIP switch bit 0. To start C= emel FORTH, when set DIP switch bit 1 to '0' after power up, it will enter Camel FORTH.

The Intel hex file fo= r the monitor program including new commands and Camel FORTH is here, 8051SBC.= HEX.

Below is the sample o= f new commands.
 

8= 051SBC Microprocessor Learning Board

ADDR:8000> Help<= /span>

Standard Commands
  ?- This help li= st
  M- List program= s
  R- Run program<= /span>
  L- Download
  U- Upload
  N- New location=
  J- Jump to memo= ry location
  H- Hex dump ext= ernal memory
  I- Hex dump int= ernal memory
  E- Editing exte= rnal ram
  C- Clear memory=
User Installed Command= s
  D- Disassemble<= /span>
  S- Single-Step<= /span>
  Q- Quick home
  Z- ZAP EEPROM
  W- NEW COMMANDS=

ADDR:8000>

Notice that letter D = is now changed to Disassemble, and L changed Load Intel hex file. Command Q will g= et back to address 0x8000. Z command still exists. Now let see new command with letter W.
 

A= DDR:8000>  NEW COMMANDS
 

8051SBC new commands (press ? for help or q to quit)

>>

Help Menu A ASCII Table <= br> D Dec2Hex
R Read GPIO2 Q Quit
I i/o address <= br> B Binary image =
? help

>>Decimal to = Hex converter

Enter decimal numbe= r =3D -32768
Dec -> Hex -> Bi= n
-32768 -> 8000 -> 1000000000000000

>>Read GPIO2 = (8-bit input port)

FD 11111101 =

>>i/o address decoded by PLD

LCD   com= mand write     0x0000
LCD   data write        0x0001
LCD   command read      0x0002
LCD   data read         0x0003
GPIO1 8-bit output port 0x0100
GPIO2 8-bit input = ; port 0x0200
expansion i/o space     0x0300-0x07FF

>> 

Now let make DIP swit= ch bit 1 to '0' and then power up the board.
 

8= 051 CamelForth v1.6 27 Mar 2000
 ok
2a emit *ok
 ok
: star 2a emit ; ok
 ok
 ok
star *ok
 ok
 ok

The sample above is a common first word for FORTH beginner. We define word 'star' with 2a put to = data stack and emit it to screen. I used to try FORTH with my design 80C88, sinc= e I was a student in 1984. However the Harvard architecture of 8051 may not suitable to make use of FORTH more efficient. The reason why I added FORTH = to the 8051 board is just to experiment the startup booting.

RS48= 5

I found some board ha= s a problem on serial port. When power up the board, the prompt was printed on screen repeatedly. I fixed it by adding a 4.7k pull-up resistor at pin 1 of 75176 RS485 driver. See the picture below.

 

Down= load
 

Schematic

8051SB= C.pdf

Monitor program 

8051SB= C.asm
myext= ra1.asm
new.c

Intel Hex files 

mypaulm2.hex
myextra1.hex=
new.hex<= /p>

Intel Hex file (three files) 

8051SB= C.hex

8051SBC Reference Manual

8051SBCreference.pdf

PCB gerber files

805= 1gerber.zip

OrCAD 9.1 MAX file

8051s= bc.max

OrCAD 9.1 Schematic and Netlist files

o= rcad8051sbc.zip

8051SBC BOM

bom= 8051sbc.txt

Equation and JEDEC file for GAL16V8D

8051sb= c.eqn
8051sb= c.jed

Cont= ribution to 8051SBC



30 Nov 200= 3