cancel
Showing results for 
Search instead for 
Did you mean: 

DAC control register

ezechkiel_9
Associate
Posted on March 11, 2011 at 10:15

hi,

i use a STM 32 discovery , and i would like to use the DAC without the library.

i make my driver , a pointer initialised on the address 0x4000 7400, and a function for write the value 0x0003 0003 in the control register.

But when i debug step by step my Control register keeps to 0, and when i write in the window control same problem my control register keeps to 0.

I link my program.

this is my main function:

#include ''DAC_struct_h.h''

#include ''CDSE_struct.h''

int main(void)

{

ptr_DAC_perso = (volatile struct DAC_perso *) 0x40007400;

CDSE_DAC_init();

unsigned int Dac_out_perso1_init,Dac_out_pe rso2_init,Dac_out_perso1,Dac_o ut_perso2,DAC_test_init;

DAC_test_init = ptr_DAC_perso -> CDSE_CTRL_REG.Global ;

Dac_out_perso1_init= ptr_DAC_perso -> CDSE_DAC_DOR1.Global ;

Dac_out_perso2_init= ptr_DAC_perso -> CDSE_DAC_DOR2.Global ;

while (1)

{

ptr_DAC_perso -> CDSE_DAC_DHR12R1.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR12L1.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR8R1.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR12R2.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR12L2.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR8R2.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR12RD.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR12LD.Global = 0xFFFFFFFF ;

ptr_DAC_perso -> CDSE_DAC_DHR8RD.Global = 0xFFFFFFFF ;

Dac_out_perso1= ptr_DAC_perso -> CDSE_DAC_DOR1.Global ;

Dac_out_perso2= ptr_DAC_perso -> CDSE_DAC_DOR2.Global ;

}

}

this is my driver:

#ifndef DAC_struct_h_

#define DAC_struct_h_

struct CTRL_REG_bitfield_acces

{

unsigned int EN1 :1;

unsigned int BOFF1 :1;

unsigned int TEN1 :1;

unsigned int TSEL1 :3;

unsigned int WAVE1 :2;

unsigned int MAMP1 :4;

unsigned int DMA_EN1 :1;

unsigned int DMAU_DRIE1 :1;

unsigned int reserve1 :2;

unsigned int EN2 :1;

unsigned int BOFF2 :1;

unsigned int TEN2 :1;

unsigned int TSEL2 :3;

unsigned int WAVE2 :2;

unsigned int MAMP2 :4;

unsigned int DMA_EN2 :1;

unsigned int DMAU_DRIE2 :1;

unsigned int reserve2 :2;

};

union CTRL_REG_acces

{

struct CTRL_REG_bitfield_acces CTRL_REG_bitfield;

unsigned int Global;

};

.

.

.

.

struct DAC_perso

{

union CTRL_REG_acces CDSE_CTRL_REG;

union DAC_SWTRIGR_access CDSE_DAC_SWTRIGR;

union DAC_DHR12R1_access CDSE_DAC_DHR12R1;

union DAC_DHR12L1_access CDSE_DAC_DHR12L1;

union DAC_DHR8R1_access CDSE_DAC_DHR8R1;

union DAC_DHR12R1_access CDSE_DAC_DHR12R2;

union DAC_DHR12L1_access CDSE_DAC_DHR12L2;

union DAC_DHR8R1_access CDSE_DAC_DHR8R2;

union DAC_DHR12RD_access CDSE_DAC_DHR12RD;

union DAC_DHR12LD_access CDSE_DAC_DHR12LD;

union DAC_DHR8RD_access CDSE_DAC_DHR8RD;

union DAC_DOR1_access CDSE_DAC_DOR1;

union DAC_DOR2_access CDSE_DAC_DOR2;

union DAC_SR_access CDSE_DAC_SR;

};

volatile struct DAC_perso *ptr_DAC_perso;

#endif

and my function write :

#include ''CDSE_struct.h''

#include ''DAC_struct_h.h''

void CDSE_DAC_init(void)

{

ptr_DAC_perso -> CDSE_CTRL_REG.Global = 0x00030003 ;

}

if you have a solution for my problem , i would sincerely happy.

Thank a lot
2 REPLIES 2
Posted on March 11, 2011 at 13:51

But when i debug step by step my Control register keeps to 0, and when i write in the window control same problem my control register keeps to 0.

 

Might help a lot of you enable the DAC's clock on the APB

RCC_APB1Periph_DAC

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ezechkiel_9
Associate
Posted on March 21, 2011 at 09:24

thank for your help ; it's work since one week  .