No volatile parameter in ASF/AVR32

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



I was wondering why this function:

bool udd_ep_run(udd_ep_id_t ep, bool b_shortpacket, uint8_t * buf, iram_size_t buf_size, udd_callback_trans_t callback)

in usb_device.c dosen't require the buf to pass as pointer to a volatile uint8_t? The buf is transfered via the usb peripheral which has its own dedicated dma.

The reasion why I thought the parameter needs to be volatile is that the buffer might change but the compiler dosen't know about it so it might optimise the code in a sense that the data is always the same?


In udi_cdc.c which uses the udd_ep_run function the data buffer is also declared without a volatile:

//! Buffer to receive data
COMPILER_WORD_ALIGNED static uint8_t udi_cdc_rx_buf[UDI_CDC_PORT_NB][2][UDI_CDC_RX_BUFFERS];

So why is its ok to declare a buffer for a dma without volatile?

Last Edited: Wed. Aug 28, 2019 - 04:17 PM