Programmer EN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Page 1

MS Micro Controller
MS Designed By Origin-gd Tech

MS8xF Application Document


User Response Manual
8- bit FLASH full series with EEPROM microcontroller

Page 2

MS8xF User Response Manual


table of Contents
Chapter 1 Frequently Asked Questions of Emulator........................................... . ....................................... .............. 1

1. How to determine the version of the emulator and upgrade the software and firmware? ................................. .................. 1

2. Can I download HEX to the chip with an emulator? ..................................... ............ ........................... 1

3. During simulation, can PA0 and PA1 continue to be used as ordinary IO ports? ............................ 1

4. How to use the emulator for debugging? ........................................ ......... ......................................... ...... 1

5. How to deal with the download failure during simulation? ...................................... ........... ........................... 2

6. How to perform external power supply simulation through the simulator? ..................................... ............ ........................... 2

Chapter 2 Frequently Asked Questions of the Writer and the Software of the Writer... ................................. ............. 3

1. How to power the writer and what is the power supply voltage? ................................... .............. ........................... 3

2. How to see if the writer is connected to the computer? .................................... ............. ................................... 3

3. Where can I view the burner software version and the burner firmware version, and how to update? ............................. 3

4. How to import HEX and EEPROM.BIN into the writer software? ................................... ............... ................. 3

5. Do I need to set the configuration bit before importing the compiled HEX to the writer? ............................... .......... 3

6. How to set the programming voltage of the writer? ...................................... ........... ....................................... .... 4

7. What are the functions of the Auto Program button of the writer software and other buttons such as Erase and Blank Check? .......... 4

8. There is no MS84Fxx04 series model in the writer software? ..................................... ............ ....................... 4

9. How to prompt if the programming is successful or failed? ..................................... ............ ...................................... ..... 4

10. HEX has been encrypted, there is information that can be read by the burner? ................................ ................. .. 4

Origin-gd Tech
11. How to read back the check code of the chip through the writer? .................................. ............... ..................... 4

12. How to connect the burner to the automatic burner to burn? .................................... ............. ......................... 5

13. How to realize the function of only checking Checksum and not burning through the burner? ................................ ............. 5

14. Can the programmer only connect to four wires VCC, GND, CLK, and DAT for programming? ............................. .......... 5

15. The writer succeeded in programming the chip for the first time, but what was the reason for the failure in the second time? ....................... ............5

16. How to use the writer to burn the chip on the board? ................................... .............. .................................... . 6

17. Support jumper cap jumper, how to use the model of programming holder? ........................ ............... ............. 6

18. How to use a burner to burn in rolling code? ..................................... ............ ............................... 1 1

Chapter 3 ORIGINIDE FAQ............................................ .. ............................................... ... . 1 2

1. Can the two platforms of MPLAB IDE or MPLAB X IDE be used to develop MS microcontrollers? ................. 12

2. I am not used to editing code on ORIGINIDE platform, can I edit it with other code editing software? ........ 12

www.origin-gd.com

Page 3

MS8xF User Response Manual


3. When programming in C language, it prompts "This Language Toolsuite is not Exists" when compiling? ......... 12

4. Prompt "File not exist" or "No such fileor diretory", how to deal with the included header file? ......... 12

5. How to add custom header files to the project? ...................................... ........... ......................... 1 3

6. When using the new ORIGINIDE to compile the old project, the pop-up compile option is gray, how to deal with it? ........ 13

7. When the emulator is emulating, can the PA0 and PA1 of the chip continue to be used as ordinary IO ports? ..................... 13

8. Does the watchdog have any effect when using ORIGINIDE emulation? ..................................... ............ .......... 1 3

9. The same project can be compiled and passed on other computers, but not on some computers? ............... 13

10. How to export an EEPROM file in ORIGINIDE? ....................................... .......... ........ 1 4

11. Can only HEX files be burned by ORIGINIDE? ....................................... .......... ........... 1 4

Chapter 4 Compilation Common Questions............................................. ................................................ .. ............. 1 5

1. How to call the header file? ......................................... ........ .......................................... ....... ....... 1 5

2. When using assembly programming, how to protect the interrupt on site? ................................... .............. ................. 1 5

3. After the chip is initialized, why does it not work to operate the common IO register PORTA/PORTC? ....................... 16

4. Why is the IO pin not high when the chip IO is pulled up internally? ................................ ........16

5. How can the lowest standby current be achieved when the chip sleeps? ................................... .............. ................. 1 6

6. What is the function of the pseudo instruction BANKSEL? ...................................... ........... ................................. 1 6

7. The problem of assembly instruction time? ......................................... ........ .......................................... ....... 1 6

Chapter 5 Common Problems of C Language........................................... . ....................................... ............. 17

1. About header file inclusion.................. .......................... ....................... ................. 1 7

Origin-gd Tech
2. About EEPROM initialization............................................ .................................................. ....... 1 7

3. About configuration bit configuration............................................ .................................................. ................ 1 7

4. About interrupt service function.................. .......................... ....................... ............. 1 7

5. Regarding interruption on-site protection............................ .............. ................................... ............. 1 7

6. Regarding the interrupt priority... ......................................... ........ ................. 1 7

7. About the interrupt flag............................................ .................................................. ................ 1 7

8. Regarding the operation of special registers and RAM, bank switching........................... . .......................... 1 8

9. About the definition of _XTAL_FREQ... ........................................ ......... .... 1 8

10. Regarding integer variable types............................................ . ....................................... ............ 1 8

11. Regarding constant types and formats........................................... . ....................................... ........ 1 9

12. Regarding bit data types and variables... ....................................... .......... ..... 2 1

www.origin-gd.com

Page 4

MS8xF User Response Manual


13. Regarding standard type qualifiers... ......................................... ........ ........ 2 1

14. On the optimization of C compiler... ....................................... .......... ......... 2 2

Chapter 6 Frequently Asked Questions about Using MS8xF ... ....................................... .......... .... 2 4

1. Is the internal circuit of the chip the same for models of the same series? ................................ ................. ............. 2 4

2. How to initialize the unpackaged IO port? ........................................ ......... ............ 2 4

3. How many points should be paid attention to in low-power applications? .................................. ............... ................................... .. 2 4

4. The IO of MS81F still cannot input or output normally after TRIS (such as TRISA) register is set? ....... twenty four

5. The IO of MS83F still cannot input or output normally after setting TRIS and CMCON0 registers? ............ 25

6. After setting TRIS, CMCON0 and ANSEL on the IO of MS84F, it still cannot input or output normally? ......... 25

7. What are the clock cycle and instruction cycle of MS microcontroller? .................................... ............. ....... 2 5

8. How to clear the interrupt with IO level change interrupt (IOCA)? ........................ ............... ............. 2 5

9. Precautions for internal fixed reference voltage of MS83F and MS84F...................................... .................... 2 5

10. When using ADC, the converted AD value is inaccurate... ................................... ..... 2 6

11. Why do LCALL and LJUMP with more than 2K space in the assembler go wrong......................... .... 2 6

contact us................................................ .................................................. ............................... 2 7

Origin-gd Tech

www.origin-gd.com

Page 5

MS8xF User Response Manual


Chapter 1 Common Problems of Emulator

1. How to determine the version of the emulator and upgrade the software and firmware?

The simulation tool is divided into three parts:


• Emulator PC software (ORIGINIDE)
• Simulator (Link)
• Firmware FW of the emulator
1. The version information of ORIGINIDE can be viewed in the "Menu Bar-Help-About..." of the ORIGINIDE interface,
Such as 1.9.5. It can be upgraded by requesting through QQ and FAE or downloading the latest IDE software on the official website;
2. The version of Link is less updated, and the version silkscreen is printed on the PCB panel, such as Link_V2.5;
3. The firmware FW version information of the emulator can be displayed in the lower right corner of ORIGINIDE after the Link is plugged into the computer.
For example, FW Ver: VF0.00.00.12, generally upgrade with the version of IDE, if you need to upgrade or downgrade manually, click
IDE "Menu Bar-Help-Update Firmware..." to update the firmware, the update file is saved in ORIGINIDE "Install
Installation directory \Update\AppUpdate.bin";

2. Can I download HEX to the chip with an emulator ?

Not possible. If you want to download the program with the chip, you can only click build all and download the program after the compilation is passed
To the chip. That is to say, it is necessary to have source code that can be effectively compiled successfully, before the HEX program corresponding to the source code
Download to the chip. At the same time, the configuration bit of the program downloaded through build all is consistent with the configuration bit set by the user.
For example, CPD has selected Enable, and the downloaded chip is already code protected.

3. During simulation, can PA0 and PA1 continue to be used as ordinary IO ports?

Not possible. During simulation, LINK will occupy PA0 and PA1 to communicate with the chip internally, so it can't be used as normal during simulation.

Origin-gd Tech
IO port use. After the download is complete, disconnect from LINK, and re-power on, PA0 and PA1 can achieve normal
IO port function.

4. How to use the emulator for debugging?

1. After connecting the emulator LINK to the computer with USB, select the LINK with the 3 voltage options in the upper right corner.
Power supply mode for the chip-the emulator supplies power to the chip and the external power supply supplies power to the chip.
a. There are 3 voltage options for the emulator to power the chip: 3.3V, 3.7V, 5V
b. To supply power to the chip from an external power supply, jump the jumper to the External, and connect the external power supply VCC to the P1 terminal of the emulator
Connect the external power supply GND terminal to the GND of the P1 port of the emulator, and the external power supply voltage cannot exceed
5.5V;
Note: When using the power supply voltage of the emulator, external power supply to the target board is prohibited. Loading two power supplies at the same time has a great risk of damage
Bad Link

2. Connect the four pins VCC, GND, CLK, and DATA on the right side of the LINK to the VCC, GND, PA0, and
PA1;
3. After opening the project, click the Build All button and the compilation options will pop up. After the compilation options are selected, ORIGINIDE is

www.origin-gd.com Page:1

Page 6

MS8xF User Response Manual


The program can be downloaded to the chip via LINK. After the download is complete, it will automatically enter the DEBUG interface, use DEBUG
The icon on the toolbar can be used for simulation debugging.
Note : Download the program chip through the emulator
It should be noted that because the emulator needs to re-power on the MCU when downloading the program, so when downloading
The target board cannot be connected to an external power supply, and it is best not to have large capacitors on the board that will affect the re-power on of the chip, PA0 and PA1
It is best not to have other components that affect the level state of the debug pin;
4. Simulate debugging and download the program to the chip. Don't open multiple projects at the same time to avoid download errors;

5. How to deal with the download failure during simulation?

The download failure is generally divided into two cases, one is to use Link to connect the chip alone to download the failure, and the other is to use on-board debugging
The download failed at the time.
In view of the first case, the analysis is divided into the following steps:
1. Check whether multiple projects are opened at the same time;
2. Check whether the firmware version of ORIGINIDE and Link is the latest;
3. Check if the connection between Link and chip is correct and stable. Note that PA0 of the chip is the clock pin, connected to the CLK of Link,
The PA1 of the chip is the data pin, which is connected to the DATA of Link. The opposite of this PIC (the RA0 of the PIC is the data pin
ICSPDAT, RA1 is the clock pin ICSPCLK);
4. Check whether the voltage of LVR in the code option is higher than the output voltage of Link. If the chip has been successfully burned
The LVR setting is higher than the output voltage of Link. Before entering the programming mode, the chip is already low due to LVR.
Press reset, so the programming will fail. The chip must be erased separately ("Debug"->"Erase" in the menu bar),
Burn again
5. Check if WDTEN is selected as Enable in the compilation options, it should be Disable. If the core has been burned successfully
The timeout time of the WDTCON register of the chip is set to a lower value, which will cause the program to be programmed again before the program is successfully programmed.
WDT timeout reset. Also need to erase the chip separately (menu bar "Debug" -> "Erase"), and then
Burn
6. Check if the chip model is mixed, replace the chip for test.
7. Check whether the Link is normal, and replace the Link test;
For the second case, analyze it in the following steps:

Origin-gd Tech
1. Use Link to connect the chip separately, and check according to the first situation. If it can be downloaded, proceed to the next step;
2. Check if there is a large capacitance between VCC and GND of the board chip, if so, please remove it;
3. Check whether there are capacitive devices or other components on the CLK and DAT pins of the chip that affect the download communication level;
4. Check whether the reset pin function of the chip is turned on. Set MCLRE in the compile option to PA3/PA5;

6. How to perform external power supply simulation through the simulator?

1. Change the voltage selection jump of the emulator from 3.3V/3.7V/5.0V to External;
2. Connect the external power supply VCC terminal to the VCC of the P1 port of the emulator;
3. Connect the GND terminal of the external power supply to the GND of the P1 port of the emulator;

4. The external power supply voltage cannot exceed 5.5V ;


5. The resistance of the power cord for external power supply should be as small as possible;
Note: When using the power supply voltage of the emulator, external power supply to the target board is prohibited. Loading two power supplies at the same time has a great risk of damage
Bad Link

www.origin-gd.com Page:2

Page 7

MS8xF User Response Manual

Chapter 2 Frequently Asked Questions about Burner and Burning Software

1. How to power the writer and what is the power supply voltage?

There are 2 ways to power the writer:


a. Power supply through the USB port, the power supply voltage is 5V Type B USB;
b. It is powered by DC, and the power supply voltage is 7.5V or 9V;
Note: The output current of the power supply must be higher than 500mA . If the LCD display is abnormal after power-on, please replace it with a larger power

Power supply .

2. How to see if the writer is connected to the computer?

First connect the burner to the computer via a USB cable. After the driver is installed (the driver comes with the burner), open the burning software
Pieces. If the version number of the burner appears under the Guangdong origin LOGO on the upper right of the burning software, such as: DRV Ver:
02.00.00.09 means that it has successfully connected to the computer.

3. Where can I view the burner software version and the burner firmware version, and how to update?

The software version number of the writer is displayed in the upper left corner of the software, such as OriginWriter V3.4.
The burner firmware version number is displayed after DRV Ver under the icon at the top right of the burner software, such as V2.1.4.
The firmware can be upgraded or downgraded by clicking the small icon above DRV Ver:. After clicking the icon, a confirmation box will pop up,
After confirming, wait for about 2 minutes, the writer will automatically complete the update.
After the firmware update is complete, you need to re-plug the USB and reconnect. After the re-connection is successful, the current DRV Ver will be displayed.
Previous firmware version number.

4. How to import HEX and EEPROM.BIN into the writer software ?

Origin-gd Tech
a. After selecting the chip model, the writer software will automatically pop up the burn file directory option box;
b. If you need to burn HEX files, select HEX files. If you do not need to burn the HEX file, select Cancel.
After the selection is completed, the burner will automatically pop up the directory option box, select the EEPROM file;
c. If you need to burn EEPROM, select BIN file. If you do not need to burn the BIN file, select Cancel;
Select the HEX file separately, the writer will only burn the corresponding program area and will not affect the original EEPROM number of the chip
according to;
d. Select the EEPROM file separately, the writer will only burn the corresponding EEPROM area, and will not affect the original chip
Program data;
e. If neither HEX nor EEPROM is selected, the data of the chip on the writer can only be read through the programming software.

5. Do I need to set the configuration bit before importing the compiled HEX to the writer?

No need. The HEX compiled in ORIGINIDE already contains the configuration bits configured before compilation. So, guide
When importing HEX to the writer, there is no need to set configuration bits.

www.origin-gd.com Page:3

Page 8

MS8xF User Response Manual


6. How to set the programming voltage of the writer?

There is a jumper in the upper right corner of the writer, which can be adjusted to 3V or 5V. The default is to jump at 3V.

7. burner software Auto Program buttons and other Erase , Blank the Check and other press

The function of the button?


Auto Program : The writer will execute the actions of "erase", "program burning" and "program verification" in sequence
Erase : Only erase the chip (Flash and EEPROM can be selected for erasing)
Blank Check : only blank check the chip
Program : Only execute the programming action on the chip, and does not verify whether the programming is successful
Verify : Check whether the code programmed into the chip is correct (if the programming program enables CPB, it cannot be verified)
Read : read chip information (if the chip is encrypted, only EEPROM data can be read)
Setting : Set the upper limit of the number of programming
Rolling Code : Rolling code setting
Calibration Frequenccy : Calibration frequency (after ticking, the chip will automatically calibrate when the frequency deviation is detected, but
Poor calibration accuracy)
Test Frequency : Test frequency (after checking, the chip that detects the frequency offset will report an error)

8. The writer software does not have MS84Fxx04 series models?

After clicking the Device/Load button, a dialog box for selecting the chip model will pop up. If there is no serial number of the current chip,
Need to check:
1. Whether the writer is online normally. (Does the DRV Ver display the burner firmware number?)

2. Whether the burner is a yellow version burner.


3. If it is the yellow version, please confirm whether the burner firmware number is the latest version.

Origin-gd Tech
9. How to prompt if the programming is successful or failed?

When the red burning button is pressed, the green light and red light will go out together. If the programming is successful, the green light will be on; if
If the programming fails, the red light will be on and the buzzer will alarm.

10. HEX has been encrypted, there is information that can be read by the burner?

Checksum of the program in Flash area, Checksum, data in EEPROM area.

11. How to read back the check code of the chip through the writer?

Place the chip on the writer according to the programming pins or effectively connect it to the writer through a wire, click on the writer
KEY_MODE button, the writer will beep once and display “IC's checksum: “XXXX” on the display,
If this result does not appear, you need to check whether the connection is correct or whether the program is configured in external crystal mode.

www.origin-gd.com Page:4

Page 9

MS8xF User Response Manual


12. How to connect the burner to the automatic burner to burn?

PROGRAM, BUSY, OK, FAIL, GND and GND silkscreen on the back of the 20-pin horn holder of the V2.0 writer
The unmarked pins (+3V) below are connected to the START, BUSY, OK, NG,
GND, VCC. Set the start level, BUSY level, OK level, NG level in the setting options of the writer
Set it to L and use the default settings for other times.

13. How to realize the function of only checking Checksum but not burning through the burner ?

Download the program that needs to be verified into the writer, and press and hold the KKEY_MODE button until the screen shows on the writer
The working mode of the writer is “Write Flash”. At this time, press the red button to switch the writer mode to “Check
checksum num".
There are the following modes under the Write function (the writer will automatically select the mode when downloading the program, it is not recommended to switch manually):
a.Write Flash: Programming chip HEX
b.Write Flash EEPROM: Programming chip HEX and EEPROM.BIN
c.Write Fla EEP Rcode: Programming chip program HEX and EEPROM.BIN programming rolling code
d.Write Fla EEP Rd FOSC: Burn chip program HEX and EEPROM.BIN to burn rolling code and calibrate frequency
e.Write Flash Rcode: Programming chip HEX, burning rolling code
f.Write Fla Rd FOSC: Burn the chip program HEX, burn the rolling code and calibrate the frequency
g.Write Fla FOSC: burn chip program HEX and calibrate frequency
h.Write Fla EEP FOSC: burn chip program HEX and EEPROM.BIN and calibrate frequency
i.Write EEPROM: Write EEPROM.BIN
j.Write EEPROM R_code: Write EEPROM.BIN and rolling code
There are three modes under the Check function:
a.Check FOSC: Check the chip frequency (checking the chip frequency will erase the internal data of the chip, you need to re-check after checking
Burn)
b.Check Flash: Check the program (only applicable when the code is not encrypted CPB=Disable)
c.Check checksum num: Checksum of the check chip (can be connected to the machine to automatically detect)

Origin-gd Tech
14. Can the programmer only connect to four wires VCC , GND , CLK , and DAT for programming?

Can be connected. After the writer software has imported the program into the writer, it will burn the Calibration in the lower left corner of the software
Uncheck Frequency and Test Frequency, and you can burn through four wires.

15. The writer succeeded in programming the chip the first time, but what was the reason for the failure in the second time?

1. Check the programming voltage selection jump on the left side of the burner display. If the program LVR voltage selection exceeds 3V and the programming
When the programming voltage of the recorder is 3V, the first programming succeeds and the second programming fails. will
The voltage can be solved by choosing 5V. Because the 3V LVR that was burned for the first time was already created during the second burn process
If the programming voltage is still 3V, the chip will be reset directly at this time and cannot enter the programming mode. therefore
Need to jump the programming voltage setting to 5V programming.
2. Check whether the watchdog of the program programmed for the first time is turned on. If it is turned on, check the WDTCON register
Whether the frequency division ratio configured in WDTPS[3:0] is too low, causing the watchdog to overshoot before the chip is successfully programmed during programming
Time reset. If this is the case, you need to erase the chip separately and then burn.

www.origin-gd.com Page:5

Page 10

MS8xF User Response Manual


3. Check whether the FOSC in the compile option of the program is the external crystal oscillator mode. If the external crystal oscillator mode is adopted,
And the FCMEN clock failure monitoring is disabled, causing the chip to fail to start and enter the programming mode during the second programming.

16. How to use the writer to burn the chip on the board?

Connect the jumper of the writer P1 to the corresponding pin of the MCU as shown in the figure below. Online programming circuit specification: CLK
And whether there are capacitive devices or other components on the DAT pin that affect the download communication level; there should be no between VCC and GND
Large capacitance, so as not to affect the power-on again.

Origin-gd Tech
17. Support jumper cap jumper, how to use the model of programming holder?

They are MS80F0801, MS81F0802, MS81F1402, MS81F1602, MS81F1802,


MS81F2002, MS82F0802A, MS82F0802B, MS82F1402A, MS83F0802A,
MS83F0802B, MS83F1402A and MS83F1602, other models can only pass the 5 programming pins of the writer
Connect to the chip to burn.
Jumper cap jumper table:
Part NO. VCC DATA CLK GND FOSC(CLKO)

MS80F0801 3 3 2 2 4

MS81F0802 3 2 1 2 4

MS81F1402 3 6 3 2 1

MS81F1602 2 7 4 3 2

MS81F1802 4 4 2 1 3

www.origin-gd.com Page:6

Page 11

MS8xF User Response Manual


MA81F2002 4 4 2 1 3

MS82F0802A 1 5 3 4 2

MS82F0802B 1 5 3 4 2

MS82F1402A 1 5 3 4 2

MS83F0802A 1 5 3 4 2

MS83F0802B 1 5 3 4 2

MS83F1402A 1 5 3 4 2

MS83F1602 1 5 3 4 2

The direction of chip placement is as follows:


1 , MS80F0801 and MS81F0802 :

2 , MS81F1402 :

Origin-gd Tech

www.origin-gd.com Page:7

Page 12

MS8xF User Response Manual


3 , MS81F1602 and MS83F1602 :

4 , MS81F1802 :

Origin-gd Tech

www.origin-gd.com Page:8

Page 13

MS8xF User Response Manual


5 , MS81F2002 :

6 , MS82F0802A , MS82F0802B , MS83F0802A and MS83F0802B :

Origin-gd Tech
Please note: to burn these 4 types of chips, only 4 wires can be used . That is, jump the jumper cap and import the program to the burning
After installing, uncheck the Calibration Frequency and Test Frequency options in the lower left corner of the burning software .

www.origin-gd.com Page:9

Page 14

MS8xF User Response Manual


7 , MS82F1402A and MS83F1402A :

Please note: To burn these 2 types of chips, only 4- wire programming can be used . That is, jump the jumper cap and import the program to the burning
After installing, uncheck the Calibration Frequency and Test Frequency options in the lower left corner of the burning software .

Origin-gd Tech

www.origin-gd.com Page:10

Page 15

MS8xF User Response Manual


18. How to use a burner to burn in rolling code?

After importing the program, click the "Rolling Code" of the burning software, and the burning rolling code configuration information table will pop up. caution:
The rolling code value can only be rolled in the EEPROM area. It can't be in FLASH area or EEPROM like PIC
Rolling code. Therefore, to use the rolling code of the MS single-chip microcomputer, the EEPROM read command must be used in the program to read the stored
Rolling code value in EEPROM area. In addition, the rolling code only has an auto-increment mode and no pseudo-random mode.

Start Address: Rolling code start address


No. of Bytes: Rolling code value bytes
Start Value: Rolling code start value
Increment: Rolling code to increase the step distance
End Value: Rolling code end value

Origin-gd Tech

www.origin-gd.com Page:11

Page 16

MS8xF User Response Manual


Chapter 3 ORIGINIDE FAQ

1 can MPLAB IDE or MPLAB X IDE these 2 platforms to develop MS monolithic

Machine?

No, you can only use the ORIGINIDE platform to develop. Because MPLAB IDE and MPLAB X IDE do not
There are corresponding models for MS.

2. If you are not used to editing code on ORIGINIDE platform, you can use other code editing software to edit

Edit?
Yes, for example, use source insight. But it should be noted that the project must be built before editing the c code of the project. because
Use ORIGINIDE to build a project, it will automatically generate ac file with the same name as the project, and this c file is invalid
Code. If there is already ac file with the same name as the project and the code has been edited before building the project,
Such a project will replace the already written file.

3. When programming in C language, it prompts "This Language Toolsuite is not

Exists"?
Generally, it is caused by the C compiler not installed or the path of calling the C compiler execution program (pic.exe) is wrong. in
After opening a project in the ORIGINIDE directory, "Menu bar->Project->Select Language Toolsuite..."
In the pop-up box, click Browse... to select the compiler executable (pic.exe) in the installation directory of the C compiler.
can.

Origin-gd Tech
Note: If you use this C compiler to develop PIC devices, please copy the files after the C compiler is successfully installed
The copy is on another drive letter. For example, when the C compiler is installed on the C drive at the beginning, copy the C compiler file
One is in another drive letter other than the C drive. Then the device development using PIC is to use the C compiler of the C disk, and the device of MS
For software development, use another C compiler with a drive letter.

4. It will prompt "File not exist" or "No such fileor diretory" when compiling, including the header

How to deal with files?

a. When using assembly programming, the header file needs to include the header file at the very beginning: #include <header file.inc> or #include
"Header file.inc". Their differences are:
• #include <header file.inc> means to directly search for this file in the IDE software path when compiling. Such as
If yes, load directly; if not, report an error (File not exist);
• #include "Header file.inc" means first search for this file in your current project folder when compiling. in case
Yes, load this file first. If not, it will look for this file in the IDE software path.
If there is, load directly; if not, report an error (File not exist);

www.origin-gd.com Page:12

Page 17

MS8xF User Response Manual


b. When using C programming, the project must include #include "syscfg.h". If it is WIN7 and above
System, you need to close the entire project, and then let ORIGINIDE obtain administrator rights. Take WIN7 as an example: right click
Click the ORIGINIDE icon, and then run with administrator privileges.

5. How to add custom header files to the project?

At present, you can only add a custom header file by including.inc or .h in the file. After the compilation is passed, you can
It is displayed in the Include File directory of File View. It is not currently supported to manually add directly in the Include File.

6. When using the new ORIGINIDE to compile the old project, the pop-up compilation options are grayed out, why?

deal with?
This situation is usually caused by changes in the chip model of the project. Now ORIGINIDE is in accordance with the specifications
The device name is used for processing, so the device name is not the same, causing the compilation options to be blank.
Solution: Right-click on Device:xx in the File View display area, and select in the pop-up menu bar
"Project Options..." select the correct device name Device:xxxx in the pop-up option box, and click OK to correct
Often compiled.

7. When the emulator is emulating, can the PA0 and PA1 of the chip continue to be used as ordinary IO ports?

Not possible. During simulation, LINK will occupy PA0 and PA1 to communicate with the chip internally, so it can't be used as normal during simulation.
IO port use. After the download is complete, disconnect from LINK, and re-power on, PA0 and PA1 can achieve normal
IO port function.

8. Does the watchdog have any effect when using ORIGINIDE emulation?

Origin-gd Tech
During simulation, if the watchdog is enabled, pay attention to the watchdog, otherwise it will generate a reset when the watchdog overflows, so that the IDE cannot
Method to obtain the correct PC value, which results in a simulation error. It is recommended to close the watchdog during simulation and open it during normal testing
Watchdog.

9. The same project can be compiled and passed on other computers, but not on some computers.

Ever?

1. The problem of header files. In the new version of the IDE, use the C language to include syscfg.h, and the assembly language includes the chip system
Just list the header file, such as MS80Fxx01.inc.
2. The installation directory of the C compiler is wrong. Because of user authority management, some operating systems will prohibit IDE from repairing
Change the file in the C compiler under the system disk. Install the C compiler on a non-system disk, or run it with administrator privileges
ORIGINIDE can solve this problem.

www.origin-gd.com Page:13

Page 18

MS8xF User Response Manual


10. How to export an EEPROM file in ORIGINIDE ?

1. Open a project, IDE menu bar Project->Export EEPROM Data will generate a .bin type
File, save this file.
2. Since the IDE does not support online editing of EEPROM files, it is recommended to use third-party text editing software to
EEPROM file to edit, take UltraEdit as an example, use UltraEdit to open the file, click Edit->Hexadecimal
Function->Hexadecimal Edit, you can edit 256 bytes of EEPROM data.

11. Can only HEX files be burned by ORIGINIDE ?

At present, only ORIGINIDE's Build All can be used to compile and download the project. A single HEX file can only
Burn the chip through the burner.

Origin-gd Tech

www.origin-gd.com Page:14

Page 19

MS8xF User Response Manual


Chapter 4 Compilation FAQ

1. How to call the header file?

1. MS80F0601 and MS80F0801 call MS80Fxx01.INC


2. Call MS81F0802, MS81F1402, MS81F1602, MS81F1802 and MS81F2002
MS81Fxx02.INC
3. MS82F0802A, MS82F0802B and MS82F1402 call MS82Fxx02.INC
4. MS83F0802, MS83F0802, MS83F1402A and MS83F1602 call MS83Fxx02.INC
5. Calling MS84F1404, MS84F1604, MS84F2004A and MS84F2004B
MS84Fxx04.INC

2. When using assembly programming, how to protect the interrupt on site?

The interrupt vector address of the chip is 04H. When an interrupt event occurs while the program is running, the current PC value of the program will be pushed into the heap
Stack, and then execute from 04H address until RETI is encountered and the stack PC is returned. Interruption protection site and recovery
The field program needs to ensure that the W value and STATUS value remain unchanged before and after the interrupt event occurs. If rewritten in interrupt
If PCLATH is added, then a variable needs to be added to protect PCLATH. If it is not rewritten in the interrupt
PCLATH value can not be protected. The recommended procedures for on-site protection and restoration are as follows:
W_TMP EQU 0x70
S_TMP EQU 0x71
ORG 0004H
STR W_TMP
SWAPR STATUS,W
STR S_TMP
;BANKSEL PORTA
; Interrupt handler
; Interrupt handler
INT_RET:
SWAPR S_TMP,W
Origin-gd Tech
STR STATUS
SWAPR W_TMP,F
SWAPR W_TMP,W
RETI

W_TMP and S_TMP need to be defined in the address range 0x70-0x7F, which is shared by all BANKs, to prevent other
When entering the interrupt in the BANK, the interrupt information will be lost.
After interrupting to protect the scene, you need to set the BANK in the interrupt.
If the register in BANK0 is to be processed in the interrupt handler, then BANK needs to be set in BANK0.
If the register in BANK1 is to be processed in the interrupt handler, then BANK needs to be set in BANK1.
If it is not set, when the program enters the interrupt during BANK1, an error will occur when the register in BANK0 is operated.
Similarly, when entering an interrupt at BANK0, operations to the register in BANK1 will also cause an error.
Programming in C language does not need to pay attention to these matters, the compiler will automatically set it.

www.origin-gd.com Page:15

Page 20

MS8xF User Response Manual


3. After the chip is initialized , why does it not work to operate the common IO register PORTA/PORTC ?

1. Check whether the ANSEL function is closed, and set ANSEL=0;


2. Check whether the comparator function is turned off, and set CMCON0=0x07;
3. Set TRISA/TRISC;
4. Check whether MCLRE is set to MCLR in the compilation options;
5. Check whether Fosc is set to INTOSCIO in the compilation options;

4. Why is the IO pin not high when the chip IO is pulled up internally ?

To set IO as a normal IO port, you also need to set WPUAX/WPUCX, and set OPTION. 7 to 0 to enable the internal upload
Pull the main switch.

5. How can the lowest standby current be achieved when the chip is sleeping?

1. Check the status of the IO, and don't let the IO be in a floating state;
2. Check whether the ANSEL function and the comparator function are turned on;
3. Check whether the LVR function is turned on during sleep, if so, please turn it off;
4. Check whether Fosc is set to INTOSC in the compilation options, if so, please select INTOSCIO;
5. Check the reset pin setting. If the reset pin is not used or there is no reset pin, set the code option MCLRE to MCLR;
6. Check whether the watchdog is open, open or close as needed;

6. What is the function of the pseudo-instruction BANKSEL ?

The pseudo-instruction BANKSEL is a command used to set the register BANK, switch to the register behind BANKSEL
In the BANK.
Such as MS80Fxx01 and MS81Fxx02:
BANKSEL PORTA, because PORTA is in BANK0, this instruction is equivalent to BCR STATUS,5

Origin-gd Tech
BANKSEL TRISA, because TRISA is in BANK1, this instruction is equivalent to BSR STATUS,5
In MS83Fxx02, because the register page is divided into BANK0, BANK1, and BANK2. By STATUS
BIT5 and BIT6 are set, so BANKSEL PORTA is equivalent to two commands
BCR STATUS,5
BCR STATUS,6
The same BANKSEL TRISA is also equivalent to two instructions
BSR STATUS,5
BCR STATUS,6
This requires special attention when accurately calculating the number of instructions.

7. The problem of assembly instruction time

LJUMP, LCALL, RET, RETI, RETW instructions that need to jump are double instruction cycles, and other instructions are
Single instruction cycle.
BTSS, BTSC, INCRSZ, DECRSZ these instructions are double instruction cycles when the jump conditions are met, and they are not satisfied
The sufficient jump condition is a single instruction cycle.

www.origin-gd.com Page:16

Page 21

MS8xF User Response Manual

Chapter 5 Common Problems of C Language

1. About header file inclusion

Use #include at the top of the program to reference the include header file, which must include the "syscfg.h" file provided by the compiler,
Realize the declaration of special registers and other special symbols in the microcontroller. All series of MS microcontrollers rely on this header file.
There is no need to separately include the header file of the chip model, ORIGINIDE will automatically call it.
Please note: the old version calls pic.h , pic16f684.h and pic16f685.h , now you don't need to call these 3 header files.
Call syscfg.h uniformly

2. About EEPROM initialization

PIC microcontroller uses __EEPROM() instruction to initialize EEPROM, while MS microcontroller needs to call initialization
EEPROM binary file (bin) to initialize EEPROM. When using MS single chip microcomputer, there must be no
__EEPROM() This instruction prevents programming failures and program running errors. About MS single chip EEPROM
For details of initialization, please refer to the EEPROM description of the routine library.

3. About configuration bit configuration

The PIC microcontroller uses the __CONFIG() instruction to configure the configuration bits, while the MS microcontroller is clicking the build button
After that, the configuration bit information table pops up, select each item in turn, and finally click OK. The configuration bit information is set in HEX
bingo. When using MS single chip microcomputer, the __CONFIG() instruction cannot be in the program to prevent programming failure and program
Operation error.

4. About interrupt service function

Origin-gd Tech
The MS MCU interrupt vector entry is at 0x0004, and there is only one entry. Therefore, the C compiler specifies the interrupt function
The name is: void interrupt ISR(void).

5. About interruption of site protection

The C compiler will automatically generate codes for interrupting the scene protection and restoring scenes, without the need for users to write the scene protection codes themselves. Yes
It is necessary to write the site protection and recovery site code by yourself when using assembly.

6. About interrupt priority

Because there is only one interrupt vector entry, the priority of all interrupts is defined by the user. In the interrupt service letter
In the numbers, which interrupt is judged first, the priority of that interrupt is higher.

7. About the interrupt flag

The corresponding interrupt source is not enabled. Once the interrupt condition is reached, the flag bit will also be set to 1, but it will not trigger the interrupt function entry

www.origin-gd.com Page:17

Page 22

MS8xF User Response Manual


number. For example, T0IE=0, but after TMR0 overflows, T0IF will be set to 1, but will not enter the interrupt service function. This kind of
Most applications do not need to act in a very timely manner for interrupt triggering. Check this flag in the main loop to determine whether
To execute the corresponding code.

8. Regarding the operation of special registers, RAM and BANK switching

The C compiler will automatically switch the BANK according to the address allocated by the operating register, and the user does not need to switch by themselves.

9. About the definition of _XTAL_FREQ

_XTAL_FREQ is defined to tell the C compiler to run the oscillator frequency of the current code. So you can call the delayed macro.
For example: #define _XTAL_FREQ 4000000. This tells the C compiler that the current code is running on the oscillator as
In a 4MHz environment. If you need to delay one millisecond, you can write: __delay_ms(1); if you want to delay ten
In microseconds, you can write: __delay_us(10);.
At the same time, it should be noted that the C compiler runs at 4T instruction cycle by default, so when we configure the bit configuration
When the instruction cycle is 2T, the defined frequency must be multiplied by two. For example, if the oscillator is 4HMz, it must
Must be defined as 8MHz. In this way, the delay time with the delay macro is accurate.

10. About integer variable types

The C compiler supports integer data types of 1, 2, 3, and 4 bytes, as well as single-bit types. bit and short long
Types are non-standard types provided in this implementation. The long long type is the C99 standard type. All integer values use
It is expressed in little-endian format with the least significant bit (LSb) at the lower address. If no symbol is specified in the type, divide char
Types other than type (always unsigned) are all signed. bit type is always unsigned, the concept of sign bit
Meaningless. The signed value is stored as a twos complement integer value. The following table lists the data types and their corresponding
Length and arithmetic type:
Types of Length (bit) Arithmetic type
bit 1 Unsigned integer

Origin-gd Tech
signed char 8 Signed integer
unsigned char 8 Unsigned integer
signed short 16 Signed integer
unsigned short 16 Unsigned integer
signed int 16 Signed integer
unsigned int 16 Unsigned integer
signed short long twenty four Signed integer
unsigned short long twenty four Unsigned integer
signed long 32 Signed integer
unsigned long 32 Unsigned integer
signed long long 32 Signed integer
unsigned long long 32 Unsigned integer

www.origin-gd.com Page:18

Page 23

MS8xF User Response Manual


11. About constant types and formats

Constants are used to represent immediate data in source code, in contrast to variables that can store the same value. For example, 123 is a
Constants. Like all values, constants must have C type. In addition to the types of constants, there are several
One of the formats to specify the actual value.
1. Integer constant
The format of an integer constant specifies its base. The C compiler supports ANSI standard radix specifiers and is used in the C generation
Specifier that specifies a binary constant in the code.
The following table lists the format used to specify the base. Same as the letters used to specify hexadecimal numbers, used to specify binary
The letters in the system or hexadecimal base are also case-sensitive.
Base format Example
Binary 0b number or 0B number 0b10101010
Octal 0 number 0257
Decimal digital 129
Hexadecimal 0x number or 0X number 0xF7
The integer constant will have type int, long int or long long int so that the type can overflow without
Store its value under. For constants specified in octal or hexadecimal, if their corresponding signed constants are too small and
Unable to store its value, you can also allocate unsigned int, unsigned long int, or unsigned long long int
Types of.
You can change the default type of a constant by adding a suffix after the number; for example, 23U, where U is the suffix.
The following table lists the possible combinations of suffixes and types that are considered when assigning types. For example, if the suffix l is specified, and
And the value is a decimal constant, and if the long int type can store the constant, the compiler will assign the class
Type; otherwise, it will allocate a long long int type. If the constant is specified as an octal or hexadecimal constant
Quantity, unsigned types will also be considered.
suffix Decimal Octal or hexadecimal
u or U unsigned int unsigned int
unsigned long int unsigned long int
unsigned long long int unsigned long long int

Origin-gd Tech
l or L long int long int
long long int unsigned long int
long long int
unsigned long long int
u or U, and l or L unsigned long int unsigned long int
unsigned long long int unsigned long long int
ll or LL long long int long long int
unsigned long long int
u or U, and ll or LL unsigned long long int unsigned long long int
The following is an example of code that may fail because the default type assigned to the constant is inappropriate:
unsigned long int result;
unsigned char shifter;
void main(void)
{
shifter = 20;
result = 1 << shifter;

www.origin-gd.com Page:19

Page 24

MS8xF User Response Manual


// code that uses result
}
The constant 1 will be assigned the type int, so the result of the shift operation will be of type int. Although the result is assigned to long
The quantity result, its length will never be greater than the length of int, no matter how many bits are shifted to the constant. here
In the example, the value 1 is shifted by 20 bits to the left will produce the result 0 instead of 0x100000.
The following code uses a suffix to change the type of a constant to ensure that the shift result has an unsigned long type.
result = 1UL << shifter;

2. Floating point constant


Floating-point constants are of type double unless they are suffixed with f or F, in which case it is a float constant.
The suffix l or L is used to specify the long double type. The C compiler treats it as the same type as double.

3. Character and string constants


Character constants are surrounded by single quote characters', such as'a'. Character constants have int type, although the compiler may
It will be optimized to char type.
In order to comply with the ANSI C standard, the compiler does not support the use of extended character sets in characters or character arrays. Actually,
They need to be escaped with the backslash character, as shown in the following example:
const char name[] = "Bj\370rk";
printf("%s's Resum\351", name); \\ prints "Bjørk's Resumé"
This implementation does not support multibyte character constants.
String constants or string literals are surrounded by double quote characters ", such as "hello world". The class of string constants
The type is const char*, the characters constituting the string are stored in the program memory, and all the pairs that use const qualification
Like the same.
When assigning a string literal to a pointer that does not specify a const target, a common related warning is generated, for example
Such as:
char * cp = "hello world\n";
String characters cannot be modified, but this type of pointer allows writing, so this warning is generated. in order to
To prevent yourself from trying to overwrite the string, use qualifiers as follows to qualify the pointer target.

Origin-gd Tech
const char * cp = "hello world\n";
Defining and initializing arrays with strings (that is, not pointers) is an exception. Eg:
char ca[]= "hello world\n";
Actually copy the string characters to the RAM array instead of assigning the address of the character as in the previous example
Give pointers. The string literal value remains read-only, but the array is readable and writable.
For strings with the same character sequence, the C compiler will use the same storage unit and label (used to initialize
Except for strings that reside in arrays in data space). For example, in the following code snippet
if(strncmp(scp, "hello", 6) == 0)
fred = 0;
if(strcmp(scp, "world") == 0)
fred--;
if(strcmp(scp, "hello world") == 0)
fred++;
The last 6 characters in the string "world" and the string "hello world" (the last character is the nul terminator)
Will be represented by the same character in the memory. The string "hello" will not be the same character in the string "hello world"
Overlap, because the position of the nul character in the two is different.

www.origin-gd.com Page:20

Page 25

MS8xF User Response Manual


The compiler concatenates two adjacent string constants (that is, the two strings are separated by spaces only). thus:
const char * cp = "hello" "world";
The pointer will be assigned the address of the string "hello world".

12. About bit data types and variables

The C compiler supports the bit integer type, which can store the value 0 or 1. A single bit variable can be declared with the keyword bit, for example:
bit init_flag;
These variables cannot be automatic variables or function parameters, but they can be defined by static so that they can be localized in the function
Define them. Eg:
int func(void)
{
static bit flame_on;
// ...
}
By using the bit keyword in the function prototype in the usual way, the function can return a bit object. Value 1 or 0 will return
To the carry flag in the STATUS register.
The behavior of bit variables is similar to regular unsigned char variables in most respects, but they can only contain the values 0 and 1.
Therefore, a convenient and efficient way to store the logo is provided. 8 bit objects are packed into each byte of memory,
So they will not consume a lot of internal RAM.
Whenever possible, operations on bit objects are performed using single bit instructions (bsf and bcf), thus generating code access
Bit objects are extremely efficient.
It is not possible to declare a pointer to a bit type or assign the address of a bit object to any pointer. Statically
Initialize bit variables, so they must be given any non-zero starting value (ie 1) in the code itself. Unless used
Persistent is limited, otherwise the bit object will be cleared at startup.
When a longer integer type is assigned to a bit variable, only the LSb will be used. For example, if the bit variable bitvar is assigned as follows:
int data = 0x54;
bit bitvar;

Origin-gd Tech
bitvar = data;
Assignment will clear it, because the LSb of data is zero.

13. About standard type qualifiers

Type qualifiers can provide additional information on how to use the object. The C compiler supports ANSI C qualifiers and a
Some additional special qualifiers, these special qualifiers are very useful for embedded applications, and make full use of the 8-bit
MS MCU architecture.
1 , CONST type qualifier

The const type qualifier is used to instruct the compiler that an object is read-only and will not be modified. If you try to modify the sound
If it is an object of type const, the compiler will issue a warning or error.
If user-defined objects are declared as const type, they will be put into a special link to the program space
psect. Objects restricted to const type can be absolute objects. @address constructs used to place objects
At the specified address in the program memory, as shown in the following example, the object tableDef is placed at address 0x100.
const int tableDef[] @ 0x100 = {0, 1, 2, 3, 4};
Normally, a const object must be initialized at the time of declaration, because it cannot be assigned at any point in runtime.

www.origin-gd.com Page:21

Page 26

MS8xF User Response Manual


Eg:
const int version = 3;
The version will be defined as an int variable that will be placed in the program memory, and will always contain the value 3, the program will always
It cannot be modified. However, if you need to place an object in another object at a specific location in the program memory
Above, you can define uninitialized const objects, which can be very useful. Usually, uninitialized const pairs
The image will be defined as an absolute object, as shown in the following example.
const char checksumRange[0x100] @ 0x800;
The object checksumRange will be defined as a 0x100 byte character array located at the address of the program memory
0x800. This definition will not put any data in the HEX file.

2 , the VOLATILE type qualifier

The volatile type qualifier is used to instruct the compiler that there is no guarantee that an object will retain its value between two consecutive accesses.
value. This prevents the optimizer from deleting seemingly redundant references to volatile objects, as this may change the execution of the program.
Perform this quoting behavior.
All SFRs that can be modified by hardware or drive hardware are limited to volatile types, and all SFRs that may be modified by interrupt programs
This qualifier should also be used for variables. Eg:
volatile static unsigned int TACTL @ 0x160;
The volatile qualifier does not guarantee that all accesses are atomic, which is usually not the case for 8-bit PIC MCU architectures.
For all these devices, each instruction can only access 1 byte of data at most.
The code generated by the compiler for accessing volatile objects may be different from the code for accessing ordinary variables, and is used
The code for volatile objects is usually longer and slower, so use this qualifier only when necessary. However, in need
Failure to use this qualifier when necessary may cause the code to fail.
Another use of the volatile keyword is to prevent variables that are not used in the C source code from being deleted. If a non
Volatile variable is never used, or its use has no effect on the function of the program, then it may be edited
The translator was deleted before generating the code.
If a C statement contains only the name of a volatile variable, a storage unit for reading the variable will be generated and the result will be discarded.
The code of the fruit. For example, the following entire statement:
PORTB;
Will generate assembly code that reads PORTB but does not perform any operations on the value. For some need to be replied by reading

Origin-gd Tech
This is very useful for bit interrupt flag status peripheral registers. Normally, this kind of sentence will not be encoded because
It has no effect.

14. About C compiler optimization

The optimization in the C compiler can be roughly divided into C code-level optimization (the source code is converted to assembly code before
Execution) and assembly-level optimization (execute the assembly code generated by the compiler).
C code-level optimization is performed early in the code generation phase, so it has a process advantage: it is possible to perform an optimization
Means that another item can be applied later.
Since these optimizations are applied before the debugging information is generated, there is usually almost no source-level debugging of the program
influences.
Some of these optimizations are an integral part of the code generation process, so they cannot be disabled through options. The following sections
Suggestions on how to abolish some specific optimizations are given.
In the standard mode, especially in the free mode, some of these optimizations will be prohibited. Even if they are enabled, only
They are only applied when very specific conditions are met. Therefore, you may find that some lines of code are optimized,

www.origin-gd.com Page:22

Page 27

MS8xF User Response Manual


But some do not.
The main C code-level optimizations that can simplify or change C expressions are listed below.
1. Unused variables:
Unused variables in the program will be deleted. For deleted variables, memory will not be reserved for them, and they will not
It appears in any list or mapping file, and does not appear in the debugging information, so it cannot be observed in the debugger.
If unused variables are encountered, a warning is generated.
Objects qualified with volatile will never be deleted. Get the address of a variable or reference it in handwritten assembly code
The assembly domain symbols also constitute the use of variables.
2. Redundant assignment:
Subsequent unused redundant assignments will be deleted, unless the variable is of volatile type. The assignment statement will be completely deleted,
It's as if it never appeared in the original source code. No code will be generated for it, and you will not be able to enter that line in the debugger
Set a breakpoint on it.
3. Unused functions:
Unused functions in the program will be deleted. If a function is not called directly or indirectly, there is no code
Take its address and consider it an unused function. The entire function will be deleted, as if it never appeared in the original source code
Now it. No code is generated for it, and you cannot set breakpoints on lines in this function in the debugger. Alone
The assembly domain symbol of the referenced function in the established handwritten assembly module can prevent it from being deleted. The assembly code only needs to be in
Use this symbol in the GLOBAL pseudo-instruction.
Unused return expression:
Unused return expressions in the function will be deleted. If the results of all calls to a certain function discard the return value,
The return value will be considered unused. The code associated with the return value calculation will be deleted, and the function will be encoded as it is
The return type is void.
4. Constant propagation:
When the numerical content of the variable can be determined, constant propagation is performed. Does not belong to the volatile type, it can be accurately determined
Valued variables will be replaced with numeric values. For uninitialized global variables, it will be assumed that they are under any assignment
Contains zero before.

Origin-gd Tech

www.origin-gd.com Page:23

Page 28

MS8xF User Response Manual

Chapter 6 Common Problems of Using MS8xF

1. Is the internal circuit of the chip the same for models of the same series?

it's the same. For example, the internal circuits of MS80F0601 and MS80F0801 are the same.
MS80F0601 just doesn't package PA3/MCLRB and PA5. Other series (MS81F, MS82F,
MS83F and MS84F) are also the same.

2. How to initialize the unpackaged IO port?

For IO ports that are not encapsulated, if they have MCLR (reset) function, set it to MCLR in the configuration bit table,
Not as an IO port. For other IOs that are not encapsulated, if the IO port has an internal pull-up, then set it to
Digital input and enable internal pull-up. If the IO port has no internal pull-up, then set it as a digital output (digital
Both word output high and digital output low are possible).
The reason for this setting is that in low-power applications, if there are floating input pins (not packaged
The pin is considered as a floating pin), the level of the floating input pin is not fixed, and it will consume a certain amount of power in a floating state.
For example: the PA3/MCLRB and PA5 pins of MS80F0601 are not encapsulated, so PA3/MCLRB should be
The configuration bit table is set to MCLR, PA5 is set as an input pin and the internal pull-up is enabled.

3. How many points should be paid attention to in low-power applications?

1. When normal IO is in sleep, it should be set according to application requirements. If it is a normal output port, it should be set to save power
Output. If it is a normal input port, the input port should be kept at a fixed level and cannot be in a floating state
(Please pay attention to the previous point 2-" How to initialize the unpackaged IO port?") .;
2. Turn off peripherals that are not used by the chip as much as possible. Special attention: use MS83F and MS84F with ADC modules
The model of the block, if the ADON bit of the ADCON0 register is set to 1, it must be set to 0 before sleep;

Origin-gd Tech
3. After the LVR module is started, there will be a current of about 15uA, so you can choose whether to
To turn on LVR. Note: LVR can be turned on and off by software, so some application environments can do this
The same setting-when waking up, start LVR; when sleeping, turn off LVR.

4. After the IO of MS81F is set with TRIS (such as TRISA ) register, it still cannot input normally

Or output?

This situation mostly occurs in the MS81Fxx02 series. The CMCON0 register should be set to
0x07. Because this series has a comparator, and when the MCU is power-on reset, CMCOM0 is equal to 0 (compare
The comparator is turned off, and the corresponding input pin of the comparator is analog input pin). So the CMCON0 register must be set to 0x07,
Then the comparator is closed, and the corresponding analog input pin is set as a normal digital input pin.

www.origin-gd.com Page:24

Page 29

MS8xF User Response Manual


5. After setting the TRIS and CMCON0 registers, the IO of MS83F still cannot be input normally or

Output?
Because some IOs multiplex the comparator function and ADC function, and when power-on reset, the corresponding pins are all analog
To be input pin. Must be set to: CMCON0=0x07 and ANSELx=0.

6. After setting the TRIS , CMCON0 and ANSEL registers , the IO of MS84F still cannot

Normal input or output?

Check whether the USFRSEL option in the compilation options is DisUSFR, modify it to ENUSFR and change CMCON4
The CMPON[3-0] is set to 0000.

7. What are the clock cycle and instruction cycle of MS microcontroller?

1. Clock cycle:
The clock period is the oscillation period, which is the reciprocal of the clock pulse, that is, the reciprocal of the system oscillator frequency. Eg system clock
Set the internal RC oscillator to 4MHz, then the clock cycle=(1/4MHz)=0.25us.

2. Instruction cycle:
The instruction cycle refers to the time required to execute a single-cycle instruction, which consists of 4 or 2 clock cycles. Eg:
The MS80F0801 instruction cycle consists of 4 machine cycles. If the system clock is set to the internal RC oscillator
4MHz, then the instruction cycle=(1/4MHz)*4T=1us. And MS81F, MS82F, MS83F and MS84F can
To select 2T instruction cycle.
The overflow time of Timer can be calculated according to the instruction cycle. For example, the prescaler ratio of Timer0 is 1:4, and the initial value is 6, which means
Let the period be 1us. Then overflow time=(256-6)*1us*4=1000us.

Origin-gd Tech
8. With IO level change interrupt (IOCA) , how to clear the interrupt?

Each PORTA pin can be individually configured as an interrupt-on-change pin. The control bit IOCx enables or disables each
Interrupt function of each pin. PAIE enables or disables interrupt-on-change, PAIF is the interrupt-on-change flag.
For pins that have enabled interrupt-on-change, the value on the changed pin is the same as the value latched when PORTA was read last time.
Line comparison. The output of the last “mismatch” is combined with a logical OR operation, so that the value in the INTCON register
The PAIF interrupt-on-change flag bit is 1.
After the interruption occurs, the user clears the interruption in the interrupt service routine in the following ways:
1. Perform a read operation on PORTA. This will end the pin level mismatch condition;
2. Clear the flag bit PAIF.

9. Precautions for internal fixed reference voltage of MS83F and MS84F

If the ADC uses the internal reference voltage of 2V, the VCC supply voltage must be higher than 2.5V
If the ADC uses an internal reference voltage of 3V, the VCC supply voltage must be higher than 3.5V

www.origin-gd.com Page:25

Page 30

MS8xF User Response Manual


10. When using ADC , the converted AD value is incorrect?

1. Check whether the voltage of the reference source is stable. If it is an internal fixed reference, check whether it meets the requirements of point 9;
2. Check the setting of the ADCON1 register conversion clock, which must conform to the dark part of the ADC clock cycle (Tad) table;
3. Check the ADC program, after setting ADON to 1, is there a delay of about 20us, then set GO/DONE to 1;
ADC clock period (Tad) System clock frequency (Fsys)

ADC clock source ADCS[2:0] 16MHz 8MHz 4MHz 1MHz

Fsys/2 000 125ns 250ns 500ns 2.0us

Fsys/4 100 250ns 500ns 1.0us 4.0us

Fsys/8 001 500ns 1.0us 2.0us 8.0us

Fsys/16 101 1.0us 2.0us 4.0us 16.0us

Fsys/32 010 2.0us 4.0us 8.0us 32.0us

Fsys/64 110 4.0us 8.0us 16.0us 64.0us

Frc x11 2~6us 2~6us 2~6us 2~6us

11. assembler in more than 2K space LCALL and LJUMP Why wrong?

The program counter (PC) is 12 bits wide. The lower 8 bits come from the PCL register that can be read and written, and the upper 4 bits (PC[11:8]) come from
Since PCLATH, it cannot be read or written directly. Whenever a reset occurs, the PC will be cleared. The figure below shows the value installed on the PC
Two situations. Note that the LCALL and LJUMP instructions on the right of the figure, because the opcode in the instruction is 11 bits, and the core
The PC of the chip is 12 bits, so only the third bit of PCLATH is used at this time, and the 11 bits of the opcode form a 12-bit ground.
site.

Origin-gd Tech
So when using assembly programming, you must set PCLATH[3:0] to directly manipulate PCL
For LCALL and LJUMP within 2K, BCR PCLATH should be set. 3
For LCALL and LJUMP other than 2K, BSR PCLATH should be set. 3
When programming in C language, there is no need to consider this problem, the compiler will handle it automatically.

www.origin-gd.com Page:26

Page 31

MS8xF User Response Manual


contact us

Shenzhen Guangdong Origin Technology Co., Ltd.


SHENZHEN ORIGIN-GD TECH CO.,LTD

WEB: www.origin-gd.com

TEL: 0755-83666320

FAX: 0755-83666329

PHONE: 18344146830 13510476700 13902985185

FAE QQ: 2850507666

ADDRESS: Room 605 , Building E , Bantian International Center, No. 5 , Huancheng South Road , Bantian Street, Longgang District, Shenzhen, Guangdong Province

Origin-gd Tech

www.origin-gd.com Page:27

You might also like