Test Board for SST89E516RD, 64kB Flash Microcontroller

Wichit Sirichote, kswichit@kmitl.ac.th

Build a test board for experimenting program downloading with EasyIAP for the SST89E516RD microcontroller.


For the application that needs more code space and more variables especially with c programming, the NXP89V51RD is very nice with 64kB Flash memory and extra RAM. In addition, the In-Application-Programming, IAP is also very good for program development. User can load the code for testing without removing the MCU from the application board. Since the NXP89V51RD2 provides two blocks of code memory, i.e. 64kB Block 0 and 8kB Block 1. Block 0 is for user code whereas block 1 contains the boot loader firmware. For NXP89V51RD2, we can use the Flash magic for program loading. This article however describes another MCU having software compatible with 8051 and having IAP feature the same as NXP89V51RD2. The chip is Silicon Storage Technology, SST89E516RD. The test board schematic and the use of EasyIAP Boot-Strap Loader will be described.

Boot-strap loader, BSL

By default, the SST89E516RD is preprogrammed with BSL firmware in block 1. When the chip is powered on with hardware reset, the memory block 1 will be overlaid on the first 8kB of the memory block 0, thus the BSL code will be executed with the condition that the WDT must not timeout to enter the IAP operations. The bootstrap loader will be connected to the PC software controlling the hex code programming to the block 0.

Figure 1: IAP operation.

If the WDT does timeout, the CPU will execute user code in block 0 directly.
Figure 2: Run user code.

Hardware schematic

Bootstrap loading is done by using UART with auto BAUD detection. The sample test schematic needs only the RS232 level converter and hardware reset circuit. The RS232 level converter can use MAX232 for +5V logic. We will need a PC running EasyIAP and RS232 cable to connect COM port to the test board.
 
Figure 3: Test board schematic (click to enlarge). 

EasyIAP Bootstrap Loader

The latest EasyIAP software can be download from Microchip directly. Here is the example of EasyIAP Rev 6.
Figure 4: EasyIAP Bootstrap Loader Rev 6.

Connect the available COM port of the PC to the test board and power on the test board. Run the EasyIAP. Follow steps below for programming the chip.

Step 1: click OPTION to select the MCU chip, COM port.
Figure 5: Select MCU chip and COM port.

Step 2: Press and hold RESET button of the test board. Click Connect menu, below window will be displayed.
Figure 6: Click connect.

Step 3: Click OK then Release RESET button, the chip will be detected automatically. Click Read at IAP Function, the memory contents of block 0 will be read and displayed in the memory window.

Figure 7: Click Read.

Step 4: To program the chip, click Download, open the hex file to be loaded. The hex file will be programmed to the 64kB block 0. When completed, press RESET on the application board to run user code. Or Click Dnload/Run user code, the program will be operated after programming the chip.

Figure 8: Click Download to program the chip with Intel HEX file.

The sample test board with MAX7219 display board is shown in Figure 9.

Figure 9: Sample test board with MAX7219 display board.

The main parts of the test board are the SST89E516RD chip, MAX232, DB9 connector, and Reset button.

Figure 11: Main components of the test board.

Here is the close up at the MCU circuit.

Figure 12: MCU circuit

The test code in c is shown below. You may also download the HEX file for programming the chip directly.

/*
BMW E21 speedometer

Project uses SST89E516RD, 64kB Flash with IAP


*/

#include <stdlib.h>

#include "SST89x5xxRD2.h"
#include "stdio.h"

#define Voffset 0 // offset voltage

sbit SCL = P1^3;
sbit SDA = P1^4;

sbit CLK= P1^7;
sbit DIN= P1^6;
sbit LOAD= P1^5;

sbit D5 = P0^4;
sbit P2D5 = P2^4;

int digit=5;
int digit2=5;
xdata char sbuffer[8];
xdata char sbuffer2[8];
xdata unsigned char buffer[16];
char command;
int i;

char bdata flag=0;
char bdata flag1=0;
char bdata flag2=0;
char bdata flag3=0;

sbit ready = flag^0;
sbit ready2 = flag^1;
sbit terminal = flag^2;
sbit pol = flag^3;
sbit ov = flag^4;
sbit pol2 = flag^5;
sbit ov2 = flag^6;
sbit fire = flag^7;

sbit once = flag1^0;

sbit key1_press = flag2^0;
sbit channel1_display = flag2^1;

sbit key3_press = flag2^2;
sbit manual_auto = flag2^3;

sbit calibrate_mode = flag2^4;
sbit key4_press = flag2^5;
sbit key2_press = flag2^6;
sbit calibrated = flag2^7; // set when the meter has been calibrated

sbit clear_display = flag3^0;
sbit disable_key4 = flag3^1;

int V1=0;
int V2=0;
int tV1,tV2,tV3;
//unsigned int temp16;

float pH;
float temperature;

unsigned long temp32=0;

sbit RUN = P1^1;

code char convert[10] = {0x7e,0x30,0x6d,0x79,0x33,0x5b,0x5f,0x70,0x7f,0x7b};
code char title[]="\n\rDigital pH Meter V1.1 (? help)";

/* 7-segment pattern converting array
a
__ register data
f |__| b D7 D6 D5 D4 D3 D2 D1 D0
e |__| c.DP DP a b c d e f g
d
*/

char code prompt[] = "\n\r>";

char mode='a';

short tick;

int second=0;
int interval=1;

unsigned int sample=1;

//short fire=0;

xdata char xbuffer[32]; // try the expanded RAM of the RD2 chip

sbit key1 = P3^4;
sbit key2 = P3^5;
sbit key3 = P3^6;
sbit key4 = P3^7;

xdata unsigned int x[5],y[3];
xdata timer3=0;

xdata long time_up=0;

xdata int set_temperature=250; // set temperature manually, default = 25.0C

xdata float temp,mVpH;
xdata char calibrate_point=0;

// variables for linear curve fitting
xdata float sumXY,sumXX,sumYY;

xdata float X1[3],Y1[3];
xdata float sumX,sumY;
xdata long XY[3],XX[3],YY[3];
xdata float d1,d2,d3,d4,d5;
xdata float A=0.0;
xdata float b=0.0;

xdata char time_over=0;
xdata long longA,longb;

xdata long sbuffer4;
xdata long sbuffer7;
xdata long sbuffer10;


// function prototype declaration
void get_key();
void write24c16long(unsigned int address, unsigned long ddata);

 

#define POLARITY 0x20
#define OVERRANGE 0x40

#define buffer4 700 //400
#define buffer7 900 //700
#define buffer10 1400 //1000

// EEPROM address definition

#define eeprom_calibrated 0
#define eeprom_longA 2 // four bytes reserved
#define eeprom_longb 6 // four bytes reserved

#define eeprom_buffer4 10
#define eeprom_buffer7 14
#define eeprom_buffer10 18

// driver for MAX7219 display controller
// shift 32-bit data to 7219 serially

shift(long n)
{
char j;

CLK = LOAD = 0;
for(j=0; j<32; j++)
{
DIN = n&0x80000000; // send data to 7219
CLK =1; // pulse CLK
CLK =0;
n<<=1; // shift left one bit
}
LOAD =1; // pulse LOAD
LOAD =0;
}

init7219()
{
shift(0x0a010a01); /* intensity (middle) */
shift(0x0b070b07); /* scan limit 8 digits */
shift(0x09000900); /* no decode mode */
shift(0x0f000f00); /* disable test mode */
shift(0x0c010c01); /* normal operation */

}

update7219()
{
init7219(); /* reinitialize everytime entering to this function */
temp32=0;
temp32 |= buffer[8];
temp32<<=16;
temp32|= buffer[0];
shift(0x01000100|temp32);

temp32=0;
temp32 |= buffer[9];
temp32<<=16;
temp32|= buffer[1];
shift(0x02000200|temp32);

temp32=0;
temp32 |= buffer[10];
temp32<<=16;
temp32|= buffer[2];
shift(0x03000300|temp32);

temp32=0;
temp32 |= buffer[11]; // put decimal point
temp32<<=16;
temp32|= buffer[3];
shift(0x04000400|temp32);

temp32=0;
temp32 |= buffer[12];
temp32<<=16;
temp32|= buffer[4];
shift(0x05000500|temp32);

temp32=0;
temp32 |= buffer[13];
temp32<<=16;
temp32|= buffer[5];
shift(0x06000600|temp32);

temp32=0;
temp32 |= buffer[14];
temp32<<=16;
temp32|= buffer[6];
shift(0x07000700|temp32);

temp32=0;
temp32 |= buffer[15];
temp32<<=16;
temp32|= buffer[7];
shift(0x08000800|temp32);
}

void timer0_isr (void) interrupt 1 using 3
{
TH0 |= 0xdc;

timer3++;
if(++tick>100)
{
tick=0;

if(++second>=interval)
{
second=0;
fire=1;

}
}
}

void over_display()
{
buffer[3]=0x7E;
buffer[4]=0x0E;
buffer[5]=0;
buffer[6]=0;
buffer[7]=0;
}

 

void pause()
{
unsigned int i;
for(i=0; i<30000;i++)
continue;
}

void main (void)
{
SCON = 0x50; /* SCON: mode 1, 8-bit UART, enable rcvr */
TMOD = 0x21; /* TMOD: timer 1, mode 2, 8-bit reload */
TH1 = 0xfd; /* TH1: reload value for 9600 baud */
TR1 = 1; /* TR1: timer 1 run */
TI = 1; /* TI: set TI to send first char of UART */
TR0 = 1; // timer0 produces 10ms tick

T2CON = 0x00; // timer 2 is used to produce 120KHz for 60Hz and 125kHz for 50Hz
T2MOD |= 0x02;
TR2 =1;
RCAP2H= 0xFF;
RCAP2L= 0xEA; // E9 for 120kHz, EA for 125kHz

//IT0 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.2)
//IT1 =1; // falling edge of INT1
//EX0 = 1; // Enable EX0 Interrupt
//EX1 = 1; // enable EX1 interrupt
ET0 = 1; // run timer0
EA = 1; // Enable Global Interrupt Flag
RUN=1; // run the 7135

init7219();

//putstr(title);

buffer[0]=convert[0];
buffer[1]=convert[1];
buffer[2]=convert[2];
buffer[3]=convert[3];
buffer[4]=convert[4];
buffer[5]=convert[5];
buffer[6]=convert[6];
buffer[7]=convert[7];

buffer[8]=convert[8];
buffer[9]=convert[9];
buffer[10]=0x4f;
buffer[11]=convert[5];
buffer[12]=convert[1];
buffer[13]=convert[6];
buffer[14]=5;
buffer[15]=0x3d;

update7219();

 

while(1)
{

;

}
}

Figure 13: Test code that displays number on the LED display board.

The result of code running is shown in Figure 14. The main code is to write the constants data to the buffer memory i.e., buffer[0] to buffer[15] and write the data to the MAX7219 chips.

Figure 14: Result of code running on the MAX7219 display board.

Download ,Schematic test board , MAX7219 display board schematic, HEX file test code , EasyIAP Rev.6 , FlashFlex datasheet, FlashFlex parallel programming , BSL11F boot-strap loader User's guide


<

25 December 2013