Hi, Tom and Mac,
Thanks you very much. I looked up in the forum and did what others have been told. All the pin, including the unshown pin, have been set output low. The SOPT1_BKGDPE has been set to be 0. The SPMSC1_LVDE and SPMSC1_LVDSE both have been set to be 0. When I measure, the BDM Multilink is disconnectted. It seems to be better, but the supply current still has 2.6mA. How about the clock setting? Following is my code. I appreciate for your help.
With regards.
Thanks a lot.
void main(void)
{
MCU_Init(); /* Function that initializes the MCU */
GPIO_Init(); /* Function that initializes the Ports of the MCU */
ADC_Init(); /* Function that initializes the ADC*/
APCTL2_ADPC15 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL3_ADPC16 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL3_ADPC17 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
APCTL1_ADPC1 = 1; /* Select the channel for ADC input (the pin stop working as GPIO) */
SCIOpenCommunication();// Opens SCI communication
EnableInterrupts; /* enable interrupts */
RTC_Init(); /* Function that initializes the RTC*/
for(;
{
SOPT1_STOPE=1;
_Stop;
}
}
void MCU_Init(void) {
SOPT1 = 0x21; /* Watchdog disable. Stop Mode Enable. Background Pin Disable. RESET pin enable */
SCGC1 = 0x11; /* Bus Clock to ADC,SCI1 is enable */
SCGC2 = 0x04; /* Bus clock to the RTC module is enable*/
SPMSC1_LVDE = 0;
SPMSC1_LVDRE = 1;
SPMSC1_LVDSE=0;
if(NVICSTRM != 0xFF) // Set Clock 24 Mhz
ICSTRM=NVICSTRM;
else
ICSTRM=0xBC;
ICSC1 = ICSC1_IREFS_MASK | ICSC1_IRCLKEN_MASK;
ICSC2=0x00;
ICSSC = ICSSC_FTRIM_MASK;
while(ICSC1_CLKS!=ICSSC_CLKST);
}
void GPIO_Init(void) {
//Setting IO low output
PTADD=0xFF;
PTAD= 0x00;
PTBDD=0xFF;
PTBD= 0x00;
PTCDD=0xFF;
PTCD= 0x00;
PTDDD=0xFF;
PTDD= 0x00;
PTEDD=0xFF;
PTED= 0x00;
PTFDD=0xFF;
PTFD= 0x00;
PTGDD=0xFF;
PTGD= 0x00;
PTHDD=0xFF;
PTHD= 0x00;
//Setting of the pin which are used
PTADD_PTADD0 = 1;
PTAD_PTAD0 = 1;
PTDDD_PTDDD6 = 1;
PTDD_PTDD6 = 1;
PTDDD_PTDDD7 = 1;
PTDD_PTDD7 = 1;
PTEDD_PTEDD5 = 1;
PTED_PTED5 = 1;
PTADD_PTADD2 = 1;
PTAD_PTAD2 = 1;
PTCDD_PTCDD5 = 1;
PTCD_PTCD5 = 0;
PTDDD_PTDDD5 = 1;
PTDD_PTDD5 = 0;
PTCDD_PTCDD0 = 0;
PTCDD_PTCDD1 = 0;
PTBDD_PTBDD1 = 1;
PTBDD_PTBDD0 = 0;
}
void ADC_Init(void)
{
// Configures ADC peripheral (ADC clock = 8MHz)
// Selects ADC continuous conversion
ADCCFG = 0x98; /* Input clock/1. Low power, Long Sample time configuration. 10-bit conversion */
ADCSC2 = 0x00; /* Software trigger selected */
ADCSC1_ADCO = 0;
}
void SCIOpenCommunication(void)
{
if (!sci_status)
{
// Open SCI Communications
sci_status = TRUE;
// Set Baud Rate Modulo Divisor
SCI1BD = BR;
// Normal operation, 8 data bits stop and no Parity
SCI1C1 = 0x00;
// Trasmitter and Receiver Enable
//SCI1C2 = SCI1C2_RIE_MASK |SCI1C2_TE_MASK |SCI1C2_RE_MASK;
SCI1C2 = 0x0C;
SCI1C3 = 0x00;
}
}
void RTC_Init(void)
{
RTCSC=0x18;
RTCMOD=0x23;
}