8051 Specifics
Types Efficiency
First of all, you should know that 8051 ALU, which performs arithmetic operations, is optimized for working with bytes. Although mikroBasic PRO for 8051 is capable of handling very complex data types, 8051 may choke on them, especially if you are working on some of the older models. This can dramatically increase the time needed for performing even simple operations. Universal advice is to use the smallest possible type in every situation. It applies to all programming in general, and doubly so with microcontrollers. Types efficiency is determined by the part of RAM memory that is used to store a variable/constant. See the example.
Nested Calls Limitations
There are no Nested Calls Limitations, except by RAM size. A Nested call represents a function call to another function within the function body. With each function call, the stack increases for the size of the returned address. Number of nested calls is equel to the capacity of RAM which is left out after allocation of all variables.
Note: There are many different types of derivatives, so it is necessary to be familiar with characteristics and special features of the microcontroller in you are using.
Xdata Specifics
xdata
memory specifier will access either External RAM (XRAM) or Internal expanded RAM (ERAM) depending on the setting of the EXTRAM bit(bit name can vary from MCU to MCU. Consult the appropiate datasheet for more information.- Before doing this, be sure to check whether the used MCU has Internal EEPROM/External data memory access enable bit, which enables access to the on-chip EEPROM or external data memory space. Due to this, this bit has to be properly set before using appropriate memory space. Consult the appropiate datasheet for more information.
- Also, when this bit is set for accesssing on-chip EEPROM and the used address exceeds the size of EEPROM, the External data memory will be used instead.
ATMEL 8051 Specifics
- Some ATMEL MCUs feature X2 mode, which speeds up the MCU by 2 (6 oscillator periods per instruction, instead of 12).
- Port pins on certain devices may be configured to one of four modes: quasi-bidirectional(standard 8051 port outputs), push-pull output, open-drain output, or input-only. Libraries for internal MCU modules are designed in such way that user can configure which of the aforementioned modes will be used.
Silicon Laboratories 8051 Specifics
- Currently, mikrobasic PRO for 8051 supports MCUs up to 64kB of Flash memory.
- mikroBasic PRO for 8051 libraries are configured for working with bit-addressable ports only (PORT0 - PORT3), due to the Read-Modify-Write limitations.
- Silicon Laboratories MCUs can configure their pins in push-pull, open drain (with/without weak pull-ups) and analog input mode. Consult the appropriate datasheet for additional information.
- When using internal MCU modules, be aware that the Crossbar Priority Decoder settings (which are altered by enabling or disabling peripherals in the Crossbar registers), will change the pinout of the device i.e. they will map peripherals to different ports/pins.
- In mikroBasic PRO for 8051, user does not need to worry about the SFR Paging, since the SFR pages are automatically selected for the ease of coding.
- When working with
sbit
type, bear in mind that all memory specifiers and type qualifiers(xdata
,bdata
,const
,volatile
, etc.) will be inherited from the owner(defined in some external file). Example :In some file, we have a definition of the
Test_bit
(owner):dim Test_bit as sbit bdata sfr extern
In the main program
Test_bit
will, for example, point to P0.0:dim Test_bit as sbit at P0.0 ' Test_bit will inherit memory specifiers and type qualifiers from the definition, in this case sfr and bdata
What do you think about this topic ? Send us feedback!