0% found this document useful (0 votes)
21 views2 pages

Commomm

The document contains code snippets and documentation for functions related to reading dataflash, software reset, power down mode, idle mode, and delay on a microcontroller. Key functions include Read_APROM_BYTE to read from dataflash, Software_Reset for software reset of the chip, PowerDown_Mode and Idle_Mode to enter low power modes, and _delay_ for a software delay loop.

Uploaded by

Roberto Dias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views2 pages

Commomm

The document contains code snippets and documentation for functions related to reading dataflash, software reset, power down mode, idle mode, and delay on a microcontroller. Key functions include Read_APROM_BYTE to read from dataflash, Software_Reset for software reset of the chip, PowerDown_Mode and Idle_Mode to enter low power modes, and _delay_ for a software delay loop.

Uploaded by

Roberto Dias
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1 /*------------------------------------------------------------------------------------

---------------------*/
2 /*
*/
3 /* SPDX-License-Identifier:
Apache-2.0 */
4 /* Copyright(c) 2020 Nuvoton Technology Corp. All rights
reserved. */
5 /*
*/
6 /*------------------------------------------------------------------------------------
---------------------*/
7
8 #include "ms51_8k_sdcc.h"
9
10 BIT BIT_TMP;
11 unsigned char __data TA_REG_TMP,BYTE_TMP,SFRS_TMP;
12
13 /**
14 * @brief Read Dataflash
15 * @param Dataflash start address
16 * @return Dataflash Value
17 * @details None
18 **/
19 unsigned char Read_APROM_BYTE(const uint16_t __code *u16_addr)
20 {
21 unsigned char rdata;
22 rdata = *u16_addr >> 8;
23 return rdata;
24 }
25
26 /**
27 * @brief Software reset API
28 * @param Run in APROM/LDROM after reset
29 * - \ref BOOT_APROM: Run in APROM after reset .
30 * - \ref BOOT_LDROM: Run in LDROM after reset.
31 * @return None
32 * @details None
33 */
34 void Software_Reset(unsigned char u8Bootarea)
35 {
36 unsigned char boottemp;
37 boottemp = (0x80|u8Bootarea);
38 TA = 0xAA;
39 TA = 0x55;
40 CHPCON = boottemp; //software reset enable
41 }
42
43 /**
44 * @brief MCU power down mode enable API
45 * @param Enable power down mode
46 * - \ref ENABLE: Run into power down mode .
47 * @return None
48 * @details None
49 */
50 void PowerDown_Mode(unsigned char PDStatus)
51 {
52 if (PDStatus)
53 {
54 ENABLE_POWERDOWN_MODE;
55 CALL_NOP;
56 CALL_NOP;
57 }
58 }
59
60 /**
61 * @brief MCU idle mode enable API
62 * @param Enable idle mode
63 * - \ref ENABLE: Run into idle mode .
64 * @return None
65 * @details None
66 */
67 void Idle_Mode(unsigned char IdleStatus)
68 {
69 if (IdleStatus)
70 {
71 ENABLE_IDLE_MODE;
72 CALL_NOP;
73 CALL_NOP;
74 }
75 }
76
77
78 /**
79 * @brief Software loop delay by HIRC, about 3ms
80 * @param None
81 * @return None
82 * @details None
83 */
84 void _delay_(void)
85 {
86 unsigned char t1,t2;
87
88 for (t2=0;t2<0x1A;t2++)
89 {
90 for (t1=0;t1<0x7f;t1++)
91 {
92 CALL_NOP;
93 }
94 }
95 }
96

You might also like