Reads51 -- Frequently Asked Questions

Keyword

 


Q000. More info...

Q001. What is Reads51?

Q002. Reads51 free?

Q003. Why are there so many updates to Reads51?

Q004. What is RchipSim51?

Q005. Why doesn't the Reads51 C compiler generate optimized code ? How about floating point support?

Q006. Where are the run-time libraries?

Q007. How does the multitasking system work ? Where can I find out more about it?

Q008. Why does printf() in "Sio51.lib" not work with the RChipSim51?

Q009. Can I debug C code in RchipSim51 or on the board?

Q010. How do I get the "Hello World" program to work in RchipSim51?

Q011. Does the compiler support MCS-51 interrupts?

Q012. How do I access SFRs from C ? How about SFR bits?

Q013. How do I access internal direct register memory from C?

Q014. How do I insert simple assembly code into C code?

Q015. How do I force the code from the C compiler start at a specific address?

Q016. I wrote a simple one-line C program and I get 4K of HEX code.  What is going on here?

Q017. How do I use the on-chip “MOVX-type” RAM in my C code?

 

Q 0. More info... (...to top)

More information about Reads51 is available in the Reads51 help (standard windows help and HTML help) files. This website contains documentation, such as quick start tutorials and users' guides. Refer to the " documentation" section. The textbooks written by our staff is a good source for information about the 8051, the MCS-51 assembly language, C language programming for the 8051, and microcontroller applications. Refer to the "textbooks" section on this website. Also, you may drop us a line about your questions. Suitable questions will be appended to this FAQ page.

Q 1. What is Reads51? (...to top)

Reads51 is "Rigel’s Embedded Applications Development System for the 8051." It is an Integrated Development Environment (IDE).

Rigel Corporation has been building industrial OEM products for over 12 years. In the early days the engineers found the software development tools to be expensive, inadequate often buggy. Although primarily a hardware company, Rigel started writing its own "in-house" software tools. Later, as Rigel began producing evaluation boards for major microcontroller manufacturers, it began including its IDE with the hardware. The first truly integrated environment was released for DOS more than a decade ago. Rigel views its IDE as a "baseline" IDE that comes with the hardware. It illustrates how the Rigel boards may be used. The emphasis is on user friendliness and richness of examples, not generating optimized code. Reads51 is not intended as a competitor to the many truly advanced development systems in the industry. As more educational institutions began including embedded control in their curricula, and began purchasing evaluation boards from Rigel, Reads51 became a common tool for schools and universities. The features of Reads51 makes it suitable for educational and hobbyist use. However, Reads51 continues to be Rigel's primary in-house industrial software development tool.

Q 2. Reads51 free? (...to top)

Reads51 is not free software. It comes with hardware purchased from Rigel. However, it is free for educational institutions and students. Industrial users may license Reads51 (see the webpage for legal information).

Q 3. Why are there so many updates to Reads51? (...to top)

Reads51 is Rigel's primary in-house industrial software development tool. We introduce extensions and fixes as we come across them, and as our customers request them. Most of the updates are due to additional demos.

Q 4. What is RchipSim51? (...to top)

RChipSim51 is a chip simulator for the basic 8051. It used to be a separate program, originally developed for the textbook "Programming and Interfacing the 8051 Microcontroller." It is now updated and included in Reads51 as a standard module. The simulator now includes virtual ports and a virtual TTY window so that you may simulate running your code without breakpoints and interact with the ports.

Q 5. Why doesn't the Reads51 C compiler generate optimized code? How about floating point support? (...to top)

Reads51 is intended as a baseline software tool to demonstrate the capabilities of Rigel's evaluation and educational boards. The emphasis of Reads51 is on user friendliness and the richness of example programs, not the generation of optimized code. Having said that, the introduction of a compiler into Reads51 in the first place was due to the requests of our educational users. We are now being asked (mostly by our industrial customers) to improve the compiler. Perhaps if the engineers get a chance in between designing machine tool controllers, automotive electronics hardware, etc...    (Also see Q 016).

Q 6. Where are the run-time libraries? (...to top)

Reads51 v4 toolchain uses the Intel OMF-51 format. The number of segments, externs and publics are limited to 256. This is a limitation on the number of library functions you may include in your projects. Some standard C functions are written and distributed in source and compiled form.

Q 7. How does the multitasking system work? Where can I find out more about it? (...to top)

The multitasking kernel is written as a library that is to be linked with your applications. The multitasking functions were developed for the new textbook "Programming and Interfacing the 8051 Microcontroller in C and Assembly." Please refer to the textbook for a detailed explanation of the multitasking functions.

Q 8. Why does printf() in "Sio51.lib" not work with the RChipSim51? (...to top)

RchipSim51 assumes separate external code and data memory blocks. The constant string ("hello\n") in

·  ·  printf("hello\n");

is kept in code memory. The function assumes the first argument to be a pointer to character in external data memory.

·  ·  printf(char *sz,...);

The library "cSio51.lib" has a function cprintf() that assumes the first argument to be a pointer to a character in code memory. Link your application with cSio51.lib and use cprintf(). You may refer to the source code of cprintf() in project "cSio.prj" and modify it as needed.

Q 9. Can I debug C code in RchipSim51 or on the board? (...to top)

The Reads51 environment technically does not debugging (single stepping, etc.) C code. You may single step through the assembly code that is generated by the compiler, but the process is tedious and not user friendly. You may, however, use RchipSim51 to run your C code without breakpoints and interact with the ports. There are many projects and tutorials in C, which may be run in RchipSim51.

Q 10. How do I get the "Hello World" program to work in RchipSim51? (...to top)

Here's the main function:

·  ·  #include <sfr51.h> // SFRs are defined here
#include <csio51.h> // prototype of cprintf(), etc.

main(){
SCON=0x50; // start serial port
cprintf("hello world...\n\n");
while(1); // absorbing loop
}

Make sure you use cprintf() (not printf()) and include the module "csio51.lib" from the .\include directory in the project.

Q 11. Does the compiler support MCS-51 interrupts? (...to top)

Yes, indeed. Use the "interrupt" keyword in the function definition. Here's the syntax:

·  ·  void interrupt(0x13) Isr(void){
.
.
.
}

The function must be of type void-void. The vector (interrupt address) must be specified after the "interrupt" keyword. Above function is for the external interrupt INT1# with vector 0x13. Search for the keyword "interrupt" (using Reads51 find-in-files feature) and look at other examples given in the .\work directory.

Q 12. How do I access SFRs from C? How about SFR bits? (...to top)

The keywords "sfr" an "sfrbit" are provided. For example,

·  ·  sfr SBUF(0x99), SCON(0x98);

defines the two SFRs SBUF and SCON. Note that the SFR addresses follow the sfr definitions. Similarly,

·  ·  sfrbit TI(0x99), RI(0x98);

defines two bits of SCON. Again, bit addresses follow the definitions. Use these definitions in C as regular integral types.

·  ·  .
.
SCON=0x50; // note SCON is case sensitive in C.
TI=0; // clear flags
RI=0;
.
.

Search for the keyword "sfr" and "sfrbit" (using Reads51 find-in-files feature) and look at other examples given in the .\work directory.

Q 13. How do I access internal direct register memory from C? (...to top)

Define internal direct register memory as type sfr, but with addresses below 128 (0x80).

·  ·  sfr RegX(0x70), RegY(0x71);

defines two of the internal direct data registers at addresses 0x70 and 0x71 as RegX and RegY. Use these in C as regular integral types.

·  ·  .
.
if(RegX==3) RegY |= 0x33;
else RegY<<2;
.
.

Q 14. How do I insert simple assembly code into C code? (...to top)

The Reads51 compiler supports in-line assembly. Use the directives "#asm" and "#endasm" to define a block of assembly code in C.

·  ·  .
.
X=1; // C code

·  ·  #asm
setb P1.0 ; note the "asm-style" comment
#endasm

Y=0; // C code
.
.

Q 15. How do I force the code from the C compiler start at a specific address? (...to top)

The compiler simply converts the C source to assembly files.  The assembly files use the extension “src.”  The start address of the final code depends on the linker options.  In the “Assembly Options” dialog, select the “Linker Options” tab.  Specify the start address of the code and the start address of external data.  Note that global variables are stored in external data memory.  Local variables are stored on stack.  By default, the C compiler stack starts at 0x4000 of external data memory.  If you want to change this, please contact techsupport@rigelcorp.com.  You must take into account the specific memory map of your application: how much external memory is available, at what address, and do the code and external data memory blocks overlap?

Q 16. I wrote a simple one-line C program and I get 4K of HEX code.  What is going on here? (...to top)

First, right-click and use the “properties” option to see the actual size of the file.  Windows reports how much space a file takes up on disk, not the real size of the file.  Further, the actual binary file is about 40% to 45% of the HEX file.

The compiler links to a static library of size 2K (binary).  This library contains the low-level routines (such as 16-bit arithmetic routines), which may be called when computing expressions.  The Reads51 compiler is not optimized to selectively include these routines.  This makes the final code relatively large for very simple programs.  You will notice that your code binary size does not grow as much afterwards.  (Also see Q 005).

Q 17. How do I use the on-chip “MOVX-type” RAM in my C code? (...to top)

I am programming the 87C520 on the R-51PB.  It will go into an R-51SD to run in the single-chip mode.  I select the “single-chip” mode in the “build options dialog,” but it does not use the on-chip 1K RAM.  I am confused.  Please help!

The term “single-chip mode” traditionally refers to the MCS-51 architecture running with no XDATA (external data) memory.  New 8051 family controllers have on-chip external memory (XDATA).  Admittedly, “on-chip external memory” sounds self-contradictory.  That is why manufacturers often refer to the on-chip XDATA RAM as “MOVX RAM.”

The Reads51 compiler uses memory for the C stack and for the global variables.  Local variables use the C stack.  Do not select the “single-chip” mode.  Assume you have 1K of external data memory.  The 87C520 MOVX-type RAM starts at 0.  So set the XDATA parameter in the “Assembly Options / Linker Options” dialog to 0.  The global variables are placed starting at this address.  Next, set the “C Stack Base Address” in the “Compiler Options / Memory” dialog.  Its value depends on the size of global variables you have.  For example, if you want to reserve 256 bytes for the global variables, set the C stack base to 0x100.  The C stack grows upward.  It is a good idea to leave as much space for the C stack as possible. 

The on-chip XDATA memory is usually disabled upon reset to make the controller “drop-in” compatible with the standard 8051.  (For example, if the original application has memory-mapped I/O at the same XDATA addresses.)  Make sure you enable the on-chip XDATA memory as the first instruction in your code, before any variable is accessed or any function called.

The project Hello03 in the “Reads51\R51pb\ Hello03” directory illustrates these points.

 


Copyright © 2005 Rigel Corporation (content contact : webmaster)