LPC1850

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

LPC1850

296 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by g.seidl on Wed May 02 23:52:24 MST 2012
Does anybody tried to configure a port pin as a DAC output ? I tried it but without success.
Here is my code snipplet by using CMSIS functions. Any ideas ?

#define ENAIO2 *((uint32*)0x40086c90)
void main(void)
{
  unsigned int 32DacValue;
  SystemInit();
  CGU_Init();
  // 1. Init DAC P4_4 = DAC Output
  GPIO_SetDir(4, 4, 0);
  scu_pinmux(4, 4, 0, 0);
  ENAIO2 |= 1;

  LPC_DAC->CR = 0;
  LPC_DAC->CTRL = 1<<3;
  LPC_DAC->CNTVAL = 0;
  DAC_Init(LPC_DAC);
  // 2. Write to DAC
  while(1)
  {
    for(u32DacValue = 0; u32DacValue < 0x400; u32DacValue++)
    {
       DAC_UpdateValue (LPC_DAC, u32DacValue);
    }
  }
Labels (1)
0 Kudos
2 Replies

275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by PhilYoung on Sun May 13 00:37:32 MST 2012
As a general comment since I wasted some time with a similar problem recently, many pins have multiple functions,and many functions can be output to multiple pins.
If a pin is not doing what you expect first go through the complete pin configuration and make sure that you don't also have the same function selected for a different pin at the same time.

This can really screw things up.
0 Kudos

275 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by tranquang.nguyen on Thu May 10 03:18:43 MST 2012
Hi georg.seidl,

I just replaced some lines and it can run correctly:
...
// 1. Init DAC P4_4 = DAC Output
LPC_SCU->ENAIO2 |= 1;
LPC_DAC->CTRL = 1<<3;
DAC_Init(LPC_DAC);
// 2. Write to DAC
...
I tested with Keil project on Hitex LPC1850EVA-A4 Board.
Besides, the LPC18xx CMSIS package has an DAC example (Dac_Dma). You can follow this link: http://sw.lpcware.com/index.php?p=lpc18xx.git&a=summary for the latest updates of the LPC18xx CMSIS PDL.

Hope this helps you!

Best Regards,
Quang
0 Kudos