tech virt

TWR-MCF54418 DAC Module

Discussion created by tech virt on Apr 26, 2013
Latest reply on Oct 30, 2015 by TomE

Hi,

 

I am working on various peripherals of the tower board (TWR-MCF54418).

 

But for now, I am stuck at DAC (Digital to Analog Converter).

 

The problem is that when I try to read the DAC related registers (MCF_DAC0_CR, MCF_DAC0_STEP, MCF_DAC0_MIN, MCF_DAC0_MAX, and MCF_DAC0_DATA) as mentioned in section 30.3 of the MCF54418RM (http://cache.freescale.com/files/32bit/doc/ref_manual/MCF54418RM.pdf), they all return 0xFFFF.

 

Even when I configure them, they don't retain their states and immediately over-written as 0xFFFF.

 

I have configured the MISCCR2 as 0xE861 to enable both the DAC modules and disable the ADCs.

 

My configuration of tower module contains, TWR-MCF54418 and TWR-SER2, attached with the TWR-ELEV modules.

 

I am running Linux 2.6.29 on the said board.

 

I have tried configuring those registers on the bare board, but it returned the same behavior as well.

 

Can anyone please point out what I am missing, or where I am doing wrong?

 

Here is the code for the bare board on  Code Warrior ProfessionalEditionMCU 10.0:

#include "support_common.h" /* include peripheral declarations and more */

#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)

/* Standard IO is only possible if Console or UART support is enabled. */

#include <stdio.h>

#endif

 

#define MISCCR2 (*(unsigned short*)(0xEC09001A))

#define ADCTSR (*(unsigned short*)(0xEC09001C))

#define DACTSR (*(unsigned short*)(0xEC09001E))

#define ADC_CAL (*(unsigned short*)(0xFC094054))

#define PPMHR0 (*(unsigned int*)(0xFC040030))

 

enum STATES

{

    STATE1,

    STATE2,

    STATE3,

    STATE4,

};

 

int main(void)

{

    int counter = 0;

    unsigned char state = STATE1;

 

#if (CONSOLE_IO_SUPPORT || ENABLE_UART_SUPPORT)

    //printf("Hello World in C++ from MCF54418 derivative on TWR-MCF5441X board\n\r");

#endif

    for(;;)

    {     

        switch(state)

        {

        case STATE1:

            MISCCR2 = MISCCR2 & 0xFFE1; //0xEC09001A

            MISCCR2 = MISCCR2 | 0x0060; //0xEC09001A

          

            printf("Register states in STATE1\n");

            printf("MISCCR2: %d\n", MISCCR2);    //0xEC09001A

            printf("ADCTSR: %d\n", ADCTSR);        //0xEC09001C

            printf("DACTSR: %d\n", DACTSR);        //0xEC09001E

            printf("ADC_CAL %d\n", ADC_CAL);    //0xFC094054

            printf("PPMHR0 %d\n", PPMHR0);        //0xFC040030

            printf("MCF_DAC0_CR: %d\n", MCF_DAC0_CR);        //0xFC098000

            printf("MCF_DAC0_STEP: %d\n", MCF_DAC0_STEP);    //0xFC098004

            printf("MCF_DAC0_MIN: %d\n", MCF_DAC0_MIN);        //0xFC098006

            printf("MCF_DAC0_MAX: %d\n", MCF_DAC0_MAX);        //0xFC098008

            printf("MCF_DAC0_DATA: %d\n", MCF_DAC0_DATA);    //0xFC098002

          

            state = STATE2;

            break;

      

        case STATE2:

            printf("Configuring Registers\n");

            MCF_DAC0_CR = 0x1101;        //0xFC098000

            ADC_CAL = ADC_CAL | 0x03;    //0xFC094054

            MCF_DAC0_STEP = 0x0004;        //0xFC098004

            MCF_DAC0_MIN = 0x0745;        //0xFC098006

            MCF_DAC0_MAX = 0xFE8A;        //0xFC098008

            MCF_DAC0_DATA = MCF_DAC0_MAX;    //0xFC098008

          

            state = STATE3;

            break;

            

        case STATE3:

            printf("Setting PDN low to activate DAC\n");

            MCF_DAC0_CR = MCF_DAC0_CR & 0xFFFE;

          

            state = STATE4;

            break;

          

        case STATE4:

            printf("MISCCR2: %d\n", MISCCR2);

            printf("ADCTSR: %d\n", ADCTSR);

            printf("DACTSR: %d\n", DACTSR);

            printf("ADC_CAL %d\n", ADC_CAL);

            printf("PPMHR0 %d\n", PPMHR0);

            printf("MCF_DAC0_CR: %d\n", MCF_DAC0_CR);

            printf("MCF_DAC0_STEP: %d\n", MCF_DAC0_STEP);

            printf("MCF_DAC0_MIN: %d\n", MCF_DAC0_MIN);

            printf("MCF_DAC0_MAX: %d\n", MCF_DAC0_MAX);

            printf("MCF_DAC0_DATA: %d\n", MCF_DAC0_DATA);

            break;

        }

    }

}

 

And here is the output of the bare board:

 

Register states in STATE1

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535

Configuring Registers

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535

MISCCR2: 59489

ADCTSR: 0

DACTSR: 0

ADC_CAL 65535

PPMHR0 2115943423

MCF_DAC0_CR: 65535

MCF_DAC0_STEP: 65535

MCF_DAC0_MIN: 65535

MCF_DAC0_MAX: 65535

MCF_DAC0_DATA: 65535




Outcomes