LPC4350 - DAC problem

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

LPC4350 - DAC problem

536 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Antony on Fri Oct 05 07:15:54 MST 2012
Hi,
I have some problem with DAC.
After configuring using driver lpc43xx_dac and selecting analog function in ENAIO2 the E3 pin (analog pin ADC0_0/ADC1_0/DAC in LPC4350FET256) remains stable and have 3.0V voltage level.
How do I configure DAC (from lpc43xx_dac driver):
/* Set default clock divider for DAC */
CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_APB3);
//Set maximum current output
DAC_SetBias(LPC_DAC,DAC_MAX_CURRENT_700uA);
//Select pin function - DAC
p->ENAIO2 |= (1<<(0));// At that stage pin E3 goes to 3.0V

After configuring I am trying to set some voltages on the DAC output, but the voltage remains the same (3.0V).
tmp = DACx->CR & DAC_BIAS_EN;
tmp |= DAC_VALUE(dac_value);
// Update value
DACx->CR = tmp;


Looks like I have missed something.
Also looks like I stuck:)
I will kindly appreciate any help.
Thanks in advance.
Labels (1)
0 Kudos
6 Replies

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by briching on Fri Dec 04 14:24:51 MST 2015
Many thanks for all this good information that was mysteriously absent from the user manual.
0 Kudos

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by adi nata on Fri May 02 07:22:58 MST 2014
thanks for the information

but for newbie like me, it takes hours to understand...

let make it easier

SystemInit();
CGU_Init();

scu_pinmux(0x4 ,4 , MD_PLN, 0); // set pin configuration register
GPIO_SetDir(0x4, 4, 0); // set GPIO port direction register
LPC_SCU->ENAIO2 |= 1; // set analog function select register

DAC_Init(LPC_DAC);
LPC_DAC->CTRL |= DAC_DMA_ENA;

int32_t iLop;

while(1)
{
for (iLop = 0; iLop < 1023; iLop++)DAC_UpdateValue(LPC_DAC, iLop);
for (iLop = 1023; iLop > 0; iLop--)DAC_UpdateValue(LPC_DAC, iLop);
}

0 Kudos

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Antony on Mon Oct 08 02:55:28 MST 2012
Hi DF9DQ,
Thanks a lot for such detailed explanation and your help.
It works now, after setting DMA_ENA bit.
Thanks you one more time.
Your help is invaluable.
0 Kudos

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DF9DQ on Sun Oct 07 15:13:00 MST 2012
Hi Martin,

I'm sure that's a typo. It's the ninth entry in a list where your choice is one out of eight. Correct is FUNC0, as that is the GPIO function, which you should make an input. As a matter of fact, the selection in the MODE field is only secondary. The choice for DAC in the ENAIO2 multiplex register gives DAC precedence over the digital function selected via MODE.

However, that fight is a sideshow...
The original question wasn't for P4_4, to which those settings apply! Antony rather uses the ADC0_0/ADC1_0/DAC signal (pin E3 of the LBGA256 package). For that pure analog pin the settings of the P4_4 config register and the ENAIO2 multiplexer are completely irrelevant. Pin ADC0_0/ADC1_0/DAC will always show the DAC output as soon as the DAC is enabled.

The missing point is probably the DMA_ENA bit in the DAC CTRL register. Despite its name this bit must be set to get a DAC output, whether you use DMA or not.

Regards,
Rolf

Edit: I should have mentioned that the existing library requires you to call DAC_ConfigDAConverterControl() in addition to DAC_Init() for the DAC to operate.
0 Kudos

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Sun Oct 07 12:00:23 MST 2012
@pboogaards

Is it correct, that you use FUNC8?

scu_pinmux(0x4 ,4 , MD_PLN, FUNC8); // DAC is function 8

I find only FUNC0 to FUNC7, no FUNC8 and according to user manual UM10503 page 292 (Rev 1.4 from Sep 2012)
the bit field MODE goes only from bit 0 to 2 and function 0 to 7?
Perhaps this is different in LPC18xx compared to LPC43xx?

Best regards,

   Martin


0 Kudos

476 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_Paul on Fri Oct 05 14:39:18 MST 2012
Antony
Have you fully configured the pin to function as a DAC?  Here's an example taken from the LPC18xx example code (available at http://www.lpcware.com/gfiles/devper/lpc18xx) to configure P4_4 as a DAC.  I tested it on a Hitex evaluation board and it works as expected.

scu_pinmux(0x4 ,4 , MD_PLN, FUNC8);  // DAC is function 8
GPIO_SetDir(0x4, 4, 0);// input mode
LPC_SCU->ENAIO2 |= 1;// Enable analog function
DAC_Init(LPC_DAC);

Regards
NXP Technical Support
0 Kudos