2 * RegisterWriteProtect.c
\r
4 * Created on: 4 Mar 2014
\r
8 #include "r_cg_iodefine.h"
\r
11 #define PRC0_BIT 0x0001
\r
12 #define PRC1_BIT 0x0002
\r
13 #define PRC3_BIT 0x0008
\r
16 void EnablePRCR( uint16_t protect )
\r
19 * PRCR Bit Register to be Protected
\r
20 * -----------------------------------------------------------------------------------------------------------------------------------------
\r
21 * PRC0 Registers related to the clock generation circuit:
\r
22 * SCKCR, SCKCR2, SCKCR3, PLLCR, PLLCR2, BCKCR, MOSCCR, SOSCCR, LOCOCR, ILOCOCR, HOCOCR, HOCOCR2, OSTDCR, OSTDSR
\r
24 * PRC1 Registers related to the operating modes:
\r
27 * Registers related to the low power consumption functions:
\r
28 * SBYCR, MSTPCRA, MSTPCRB, MSTPCRC, MSTPCRD, OPCCR, RSTCKCR, DPSBYCR, DPSIER0 to DPSIER3, DPSIFR0 to DPSIFR3, DPSIEGR0 to DPSIEGR3
\r
30 * Registers related to clock generation circuit:
\r
31 * MOSCWTCR, SOSCWTCR, MOFCR, HOCOPCR
\r
33 * Software reset register:
\r
36 * PRC3 Registers related to the LVD:
\r
37 * LVCMPCR, LVDLVLR, LVD1CR0, LVD1CR1, LVD1SR, LVD2CR0, LVD2CR1, LVD2SR
\r
39 SYSTEM.PRCR.WORD = (uint16_t)( 0xA500 | protect );
\r
42 void DisablePRCR( uint16_t protect )
\r
45 * PRCR Bit Register to be Protected
\r
46 * -----------------------------------------------------------------------------------------------------------------------------------------
\r
47 * PRC0 Registers related to the clock generation circuit:
\r
48 * SCKCR, SCKCR2, SCKCR3, PLLCR, PLLCR2, BCKCR, MOSCCR, SOSCCR, LOCOCR, ILOCOCR, HOCOCR, HOCOCR2, OSTDCR, OSTDSR
\r
50 * PRC1 Registers related to the operating modes:
\r
53 * Registers related to the low power consumption functions:
\r
54 * SBYCR, MSTPCRA, MSTPCRB, MSTPCRC, MSTPCRD, OPCCR, RSTCKCR, DPSBYCR, DPSIER0 to DPSIER3, DPSIFR0 to DPSIFR3, DPSIEGR0 to DPSIEGR3
\r
56 * Registers related to clock generation circuit:
\r
57 * MOSCWTCR, SOSCWTCR, MOFCR, HOCOPCR
\r
59 * Software reset register:
\r
62 * PRC3 Registers related to the LVD:
\r
63 * LVCMPCR, LVDLVLR, LVD1CR0, LVD1CR1, LVD1SR, LVD2CR0, LVD2CR1, LVD2SR
\r
65 uint16_t current_value;
\r
67 current_value = (uint16_t)( SYSTEM.PRCR.WORD & 0x00ff );
\r
68 current_value = (uint16_t)( current_value & ~protect );
\r
70 SYSTEM.PRCR.WORD = (uint16_t)( 0xA500 | current_value );
\r