lpcware

LPC1857 DAC not working

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by d-ito on Thu Dec 24 17:51:20 MST 2015
Hi

I try to run a sample code LPC1857FET256 DAC, but do not success.
The P4-4 outputs a zero voltage.
To simplify, I wrote a program only corresponding to DAC. However it is also not working.

I read a user manual and some topics but can not solve this problem.
Please, some advice to me.

Debugger: LPC-Link2
IDE: LPCXpresso v8.0.0
Bord: LPC1857-Xplorer++

Here is my code.
//----------------------------------------
#ifdef __LPC18XX__
#include "lpc18xx_gpio.h"
#include "lpc18xx_scu.h"
#include "lpc18xx_cgu.h"
#include "lpc18xx_dac.h"
#ifndef __CODE_RED
#include "lpc18xx_libcfg.h"
#endif
#endif


int main(void)
{
unsigned int u32DacValue;

SystemInit();
CGU_Init();
// 1. Init DAC P4_4 = DAC Output
GPIO_SetDir(4, 1<<4, 0);
scu_pinmux(4, 1<<4, 0, 0);
LPC_SCU->ENAIO2 |= 1;
LPC_DAC->CTRL = 1<<3;
DAC_Init(LPC_DAC);
while(1)
{
for(u32DacValue = 0; u32DacValue < 0x400; u32DacValue++)
{
DAC_UpdateValue (LPC_DAC, (unsigned int)(u32DacValue));
}
}
return c_entry();
}

#ifdef  DEBUG
void check_failed(uint8_t *file, uint32_t line)
{
while(1);
}
#endif

Thank you for reading,
Daisuke Ito

Outcomes