Dacc makes code hang up

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
 
I am using a atsamv71, 
 
I created this function allowing me to have a different value on the DACC channel 0 :
 

void __attribute__((tcm)) OutDAC(uint16_t dac)
 
  dac &= 0xFFFU; // bits15_12 of input value are zeroed
  // send value <dac> bits11_0 to the DAC module
  while(!DACC_IsReady(DACC_CHANNEL_0));
  DACC_DataWrite(DACC_CHANNEL_0, dac);
}

 
When doing this, the DACC is never ready and the value is never written on the channel 0.
 
What I notice is that, if i had an instruction right after the DACC_DataWrite one, like so:
 

void __atribute__((tcm)) OutDAC(uint16_t dac)
{
  dac &= 0xFFFU; // bits15_12 of input value are zeroed
  // send value <dac> bits11_0 to the DAC module
  while(!DACC_IsReady(DACC_CHANNEL_0));
  DACC_DataWrite(DACC_CHANNEL_0, dac);
  printf("----"); //AN instruction no matter what it is
}

 
The function works and the DACC is always ready and gives the right value on the DACC (channel 0) pin.
 
Do you have any idea on why this strange behavior is happening? Did I do an incorrect setting ?