no-OS
no-OS copied to clipboard
drivers:axi_core:axi_dac_core:axi_dac_core.c: Fix DAC init crash
I have problems getting the no-OS code running on AD9364. It seems there's an issue with the axi_dac_init() code which gave me CPU exceptions (division by 0).
Only tested on AD9364 (ZedBoard+fmcomms4) and there it doesn't crash anymore.
dac->clock_hz needs to be set before axi_dac_dds_set_frequency() is run. axi_dac_data_setup() is calling axi_dac_dds_set_frequency(). Hence, we need to set dac->clock_hz before axi_dac_data_setup().
Move mdelay(100) so the frequency register value has time to stabilize after reset before reading.
Ok, so I just checked the commit history. This bug seems to be introduced in commit 1bf45a05e50d13f0c73a6aa1bbe7e425e45f87f4. Before that commit the reset was done in axi_dac_init_begin(), the delay was after that call. Also the assigning of dac->clock_hz in axi_dac_init_finish() was made before calling axi_dac_data_setup().
I don't know in which functions you prefer to do what.
Sure, please test it as much as possible. It should be safe to merge though since it basically restores behavior to before 1bf45a05e50d13f0c73a6aa1bbe7e425e45f87f4.
Tried to resolve conflict with github tool but still said it had conflicts so I rebased to master and force pushed.
Closing this for now, might reconsider adapting/testing later on.