Question: Building a digital guitar effects pedal running issues that there is no sound when guitar strings or strung along with no effects I think it
Building a digital guitar effects pedal running issues that there is no sound when guitar strings or strung along with no effects I think it could be this section of my code that is causing issue since dac is constantly even hen strung this was programmed on stm cube IDE also using SPI
void ReadADCvoid
pull ADC CS low to start the conversion and start nonblocking SPI receive using DMA
HALGPIOWritePinGPIOB GPIOPIN GPIOPINRESET;
delayus; us need at least us as per ADS datasheet
HALSPIReceiveDMA&hspiuintt&adcvalue, ;
write DAC
void WriteDACuintt dacvalue
uintt data;
the bit data as per DAC datasheet
datax; Bits : unused bits control bits PD PD for normal operation
datadacvalue & xFF; Bits : High byte of the bit DAC value
data dacvalue & xFF; Bits : Low byte of the bit DAC value
Pull SYNC Chip Select low to start communication
HALGPIOWritePinGPIOB GPIOPIN GPIOPINRESET;
delayus; Small delay for timing stabilization
Transmit the bit data over SPI
HALSPITransmitDMA&hspi data, ;
Pull SYNC Chip Select high to end communication
HALGPIOWritePinGPIOB GPIOPIN GPIOPINSET;
delayus; Small delay for timing stabilization
apply effects parallel
void ProcessAudiovoid
uintt processedData ApplyEffectsParalleluintt&adcvalue; apply all active effects
WriteDACprocessedData; write the processed data to DAC
void HALTIMPeriodElapsedCallbackTIMHandleTypeDef htim
if htimInstance TIM
this interrupt occurs at kHz
ReadADC; Start ADC read
SPI transmit
void HALSPITxCpltCallbackSPIHandleTypeDef hspi
switch uintptrthspiInstance
case uintptrtSPI:
HALGPIOWritePinGPIOA GPIOPIN GPIOPINSET; SPI specific logic
break;
case uintptrtSPI:
HALGPIOWritePinGPIOB GPIOPIN GPIOPINSET; End transmission for SPI
ledtogglecounter;
break;
void HALSPIRxCpltCallbackSPIHandleTypeDef hspi
switch uintptrthspiInstance
case uintptrtSPI:
HALGPIOWritePinGPIOA GPIOPIN GPIOPINSET; SPI specific logic
break;
case uintptrtSPI:
HALGPIOWritePinADCCSnGPIOPort, ADCCSnPin, GPIOPINSET;deselect adc
adcready true;
break;
for us Conversion Time per ADC datasheet
void delayusuintt us
uintt tickstart HALGetTick; HAL tick is usually in milliseconds
while HALGetTick tickstartus ; Microsecond approximation
record audio
void RecordAudiovoid
if adcready
adcready false;
add ADC value to buffer
audioBufferbufferWriteIndex adcvalue;
if bufferWriteIndex BUFFERSIZE
bufferWriteIndex ; wrap around to maintain circular buffer
bufferCount;
if buffer is half or completely full, write to flash
if bufferCount PAGESIZE
WriteBufferedDataToFlash;
start the next ADC conversion
ReadADC;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
