DAC Sinus Demo (using PEx + KSDK 1.2 + KDS 3.0)

Document created by Iva Dorazinova Employee on May 29, 2015Last modified by jorge_plascencia on Aug 3, 2017
Version 6Show Document
  • View in full screen mode

Created DAC Sinus example is PIT triggered with own buffer and is for FRDM-K64F.

 

  • adding analog component fsl_dac peripheral driver to project

1.png

  • setting Voltage reference - Reference 2 for dac component (daConv1:fsl_dac)

2.png

  • adding timer component fsl_pit peripheral driver to project

3.png

  • setting period on 1 ms and enabling interrupts for timer component (pitTimer1:fsl_pit)

4.png

5.png

  • setting buffer for sinusoidal in Sources -> Events.c
#define DAC_TEST_BUFF_SIZE  (120U) uint16_t dac_buffer[DAC_TEST_BUFF_SIZE] =     {         
0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,        
0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,        
0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,        
0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,       
0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,        
0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,        
0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,        
0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,        
0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,        
0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,        
0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,        
0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794       };

uint16_t index = 0;
void pitTimer1_IRQHandler(void) {  

/* Clear interrupt flag.*/  
PIT_HAL_ClearIntFlag(g_pitBase[FSL_PITTIMER1], FSL_PITTIMER1_CHANNEL);  

/* Write your code here ... */   

DAC_DRV_Output(FSL_DACONV1,dac_buffer[index++]);  
if(index==DAC_TEST_BUFF_SIZE)       index = 0;  }

 

  • FRDM-K64F with SALEAE

unnamed.jpg

detail.jpg

 

  • sinusoidal output

 

vystup_.png

 

Enjoy! :-)

2 people found this helpful

Outcomes