Using DAC without PE

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using DAC without PE

Jump to solution
1,730 Views
gsanchez
Contributor III

Hi community. I have an issue here. I'm just starting with a Kinetis K60 system, and I must to use the DAC peripheral. All the app is developed in MQX in a Codewarrior project without Processor Expert. Here's my trouble: How to use this component without PE initialization? In MQXIOUG says that in "bsp.h" are included all the files for this, but my bsp.h didn't have they. The file "user_config.h" doesn't have an "BSPCFG_ENABLE_DACx" definition, and the folder "io/dac" isn't included in BSP peripheral IO files. How can I start with this module?

Thanks a lot.

Kind regards.

0 Kudos
1 Solution
937 Views
DavidS
NXP Employee
NXP Employee

Hi gsanchez,

The Kinetis device header file (ex: MK60D10.h) has "#defines" for the DACx register to let you directly access them:

DAC1_DAT0L                               DAC_DATL_REG(DAC1_BASE_PTR,0)

DAC1_DAT0H                               DAC_DATH_REG(DAC1_BASE_PTR,0)

DAC1_DAT1L                               DAC_DATL_REG(DAC1_BASE_PTR,1)

DAC1_DAT1H                               DAC_DATH_REG(DAC1_BASE_PTR,1)

DAC1_DAT2L                               DAC_DATL_REG(DAC1_BASE_PTR,2)

DAC1_DAT2H                               DAC_DATH_REG(DAC1_BASE_PTR,2)

DAC1_DAT3L                               DAC_DATL_REG(DAC1_BASE_PTR,3)

DAC1_DAT3H                               DAC_DATH_REG(DAC1_BASE_PTR,3)

DAC1_DAT4L                               DAC_DATL_REG(DAC1_BASE_PTR,4)

DAC1_DAT4H                               DAC_DATH_REG(DAC1_BASE_PTR,4)

DAC1_DAT5L                               DAC_DATL_REG(DAC1_BASE_PTR,5)

DAC1_DAT5H                               DAC_DATH_REG(DAC1_BASE_PTR,5)

DAC1_DAT6L                               DAC_DATL_REG(DAC1_BASE_PTR,6)

DAC1_DAT6H                               DAC_DATH_REG(DAC1_BASE_PTR,6)

DAC1_DAT7L                               DAC_DATL_REG(DAC1_BASE_PTR,7)

DAC1_DAT7H                               DAC_DATH_REG(DAC1_BASE_PTR,7)

DAC1_DAT8L                               DAC_DATL_REG(DAC1_BASE_PTR,8)

DAC1_DAT8H                               DAC_DATH_REG(DAC1_BASE_PTR,8)

DAC1_DAT9L                               DAC_DATL_REG(DAC1_BASE_PTR,9)

DAC1_DAT9H                               DAC_DATH_REG(DAC1_BASE_PTR,9)

DAC1_DAT10L DAC_DATL_REG(DAC1_BASE_PTR,10)

DAC1_DAT10H                              DAC_DATH_REG(DAC1_BASE_PTR,10)

DAC1_DAT11L                              DAC_DATL_REG(DAC1_BASE_PTR,11)

DAC1_DAT11H                              DAC_DATH_REG(DAC1_BASE_PTR,11)

DAC1_DAT12L                              DAC_DATL_REG(DAC1_BASE_PTR,12)

DAC1_DAT12H                              DAC_DATH_REG(DAC1_BASE_PTR,12)

DAC1_DAT13L                              DAC_DATL_REG(DAC1_BASE_PTR,13)

... and more.

I know you do not want to use PE but for those that might I have following input:

MQX does not have DAC driver currently.  It did for a ColdFire V1 in older MQX version but has been
deprecated (such a cool word!).

I suggest customer use PE.

Start with following demo:

C:\Freescale\Freescale_MQX_4_0_CW10_4\demo\pe_demo

 

The steps that are not documented well other than when you look through the source code
are:

  • See
    "<MQX_INSTALL_DIR>\doc\tools\cw\FSL_MQX_in_CW_10_x.pdf" chapter "CW10.x,
    MQX and Processor Expert" for details

So basically open the RTOS for the Tower kit/device you have.

Use PE to generate code and then re-compile RTOS.

Open the pe_demo project; clean, build, run.

The pe_demo project is using two PE components: GPIO and PWM (really the FTM in the PWM
mode).

Once all of this has been verified to work then simple add in a DAC component into the BSP and access from
the pe_demo MQX application.

Regards,

David 

View solution in original post

0 Kudos
7 Replies
937 Views
c0170
Senior Contributor III

Hello gsanchez,

is your intention to reuse PE DAC component? What do you mean by "all app is developed" ? Is it existing project?

There's not any non-PE DAC driver in MQX therefore you won't find it in MQX anywhere.

Regards,

c0170

0 Kudos
937 Views
gsanchez
Contributor III

So, the main question is... How can I integrate the PE driver (DAC) in an application that doesn't use PE.

Thanks a lot.

0 Kudos
938 Views
DavidS
NXP Employee
NXP Employee

Hi gsanchez,

The Kinetis device header file (ex: MK60D10.h) has "#defines" for the DACx register to let you directly access them:

DAC1_DAT0L                               DAC_DATL_REG(DAC1_BASE_PTR,0)

DAC1_DAT0H                               DAC_DATH_REG(DAC1_BASE_PTR,0)

DAC1_DAT1L                               DAC_DATL_REG(DAC1_BASE_PTR,1)

DAC1_DAT1H                               DAC_DATH_REG(DAC1_BASE_PTR,1)

DAC1_DAT2L                               DAC_DATL_REG(DAC1_BASE_PTR,2)

DAC1_DAT2H                               DAC_DATH_REG(DAC1_BASE_PTR,2)

DAC1_DAT3L                               DAC_DATL_REG(DAC1_BASE_PTR,3)

DAC1_DAT3H                               DAC_DATH_REG(DAC1_BASE_PTR,3)

DAC1_DAT4L                               DAC_DATL_REG(DAC1_BASE_PTR,4)

DAC1_DAT4H                               DAC_DATH_REG(DAC1_BASE_PTR,4)

DAC1_DAT5L                               DAC_DATL_REG(DAC1_BASE_PTR,5)

DAC1_DAT5H                               DAC_DATH_REG(DAC1_BASE_PTR,5)

DAC1_DAT6L                               DAC_DATL_REG(DAC1_BASE_PTR,6)

DAC1_DAT6H                               DAC_DATH_REG(DAC1_BASE_PTR,6)

DAC1_DAT7L                               DAC_DATL_REG(DAC1_BASE_PTR,7)

DAC1_DAT7H                               DAC_DATH_REG(DAC1_BASE_PTR,7)

DAC1_DAT8L                               DAC_DATL_REG(DAC1_BASE_PTR,8)

DAC1_DAT8H                               DAC_DATH_REG(DAC1_BASE_PTR,8)

DAC1_DAT9L                               DAC_DATL_REG(DAC1_BASE_PTR,9)

DAC1_DAT9H                               DAC_DATH_REG(DAC1_BASE_PTR,9)

DAC1_DAT10L DAC_DATL_REG(DAC1_BASE_PTR,10)

DAC1_DAT10H                              DAC_DATH_REG(DAC1_BASE_PTR,10)

DAC1_DAT11L                              DAC_DATL_REG(DAC1_BASE_PTR,11)

DAC1_DAT11H                              DAC_DATH_REG(DAC1_BASE_PTR,11)

DAC1_DAT12L                              DAC_DATL_REG(DAC1_BASE_PTR,12)

DAC1_DAT12H                              DAC_DATH_REG(DAC1_BASE_PTR,12)

DAC1_DAT13L                              DAC_DATL_REG(DAC1_BASE_PTR,13)

... and more.

I know you do not want to use PE but for those that might I have following input:

MQX does not have DAC driver currently.  It did for a ColdFire V1 in older MQX version but has been
deprecated (such a cool word!).

I suggest customer use PE.

Start with following demo:

C:\Freescale\Freescale_MQX_4_0_CW10_4\demo\pe_demo

 

The steps that are not documented well other than when you look through the source code
are:

  • See
    "<MQX_INSTALL_DIR>\doc\tools\cw\FSL_MQX_in_CW_10_x.pdf" chapter "CW10.x,
    MQX and Processor Expert" for details

So basically open the RTOS for the Tower kit/device you have.

Use PE to generate code and then re-compile RTOS.

Open the pe_demo project; clean, build, run.

The pe_demo project is using two PE components: GPIO and PWM (really the FTM in the PWM
mode).

Once all of this has been verified to work then simple add in a DAC component into the BSP and access from
the pe_demo MQX application.

Regards,

David 

0 Kudos
937 Views
gsanchez
Contributor III

Hello David, thanks for your answer. It was very helpful.

Now I have another question: What if I import a DAC component in PE project and use it in my project (which do not use PE), just by copy-paste auto-generated code and adjust it to my app? Can work that?

Thanks for your answer.

Regards,

0 Kudos
937 Views
DavidS
NXP Employee
NXP Employee

Hi  gasanchez,

You can do that but I'd either use PE and then port that code to MQX to use same header files or just use the register defines that I pointed out before.  It also somewhat depends on how you are trying to use the DAC.

I did a quick test and started with the mqx/examples/adc project for TWR-K60D100M.

Using the defines I turn on the clock to the DAC0, configure it, then each time I have a 16-bit ADC channel #1 result, I convert it to 12-bit result, write to the DATL and DATH registers, and software trigger to update the DAC output that I can watch with oscope on TP8.

I've attached that example code.

Regards,

David

0 Kudos
937 Views
gsanchez
Contributor III

Hello David. Thanks for that! I will test it more later in my house, and maybe finally use PE.

thanks a lot.

Regards,

0 Kudos
937 Views
gsanchez
Contributor III

Hello Martin,

is your intention to reuse PE DAC component?

No, my intention is to use DAC module (inside MCU), without PE.

What do you mean by "all app is developed" ? Is it existing project?

I have an app developed in Codewarrior, in C language. And I want to use one DAC in that app.

There's not any non-PE DAC driver in MQX therefore you won't find it in MQX anywhere.

Ok, thanks. So the only way to use DAC is through PE, this isn't a nice way to program it.

Maybe I could reuse the driver generated by PE to realise my own driver...¿?

0 Kudos