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 0 even hen strung this was programmed on stm32 cube IDE also using SPI
void Read_ADC(void){
//pull ADC CS low to start the conversion and start non-blocking SPI2 receive using DMA
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_10, GPIO_PIN_RESET);
delay_us(2); //2us, need at least 1.4us as per ADS8319 datasheet
HAL_SPI_Receive_DMA(&hspi2,(uint8_t*)&adc_value, 2);
}
//write DAC8551
void Write_DAC(uint16_t dac_value){
uint8_t data[3];
//the 24-bit data as per DAC8551 datasheet
data[0]=0x00; // Bits 23-16: 6 unused bits +2 control bits (PD1=0, PD0=0 for normal operation)
data[1]=(dac_value >>8) & 0xFF; // Bits 15-8: High byte of the 16-bit DAC value
data[2]= dac_value & 0xFF; // Bits 7-0: Low byte of the 16-bit DAC value
// Pull SYNC (Chip Select) low to start communication
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);
delay_us(1); // Small delay for timing stabilization
// Transmit the 24-bit data over SPI
HAL_SPI_Transmit_DMA(&hspi2, data, 3);
// Pull SYNC (Chip Select) high to end communication
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);
delay_us(1); // Small delay for timing stabilization
}
//apply effects parallel
void Process_Audio(void){
uint16_t processedData = Apply_Effects_Parallel((uint16_t*)&adc_value); //apply all active effects
Write_DAC(processedData); //write the processed data to DAC
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if (htim->Instance == TIM2){
//this interrupt occurs at 44.1 kHz
Read_ADC(); // Start ADC read
}
}
//SPI transmit
void HAL_SPI_TxCpltCallback(SPI_HandleTypeDef *hspi){
switch ((uintptr_t)hspi->Instance){
case (uintptr_t)SPI1:
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // SPI1 specific logic
break;
case (uintptr_t)SPI2:
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET); //End transmission for SPI2
//led_toggle_counter++;
break;
}
}
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi){
switch ((uintptr_t)hspi->Instance){
case (uintptr_t)SPI1:
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET); // SPI1 specific logic
break;
case (uintptr_t)SPI2:
HAL_GPIO_WritePin(ADC_CSn_GPIO_Port, ADC_CSn_Pin, GPIO_PIN_SET);//deselect adc
adc_ready = true;
break;
}
}
//for 1.4us Conversion Time per ADC datasheet
void delay_us(uint32_t us){
uint32_t tickstart = HAL_GetTick(); // HAL tick is usually in milliseconds
while ((HAL_GetTick()- tickstart)<(us /1000)); // Microsecond approximation
}
//record audio
void Record_Audio(void){
if (adc_ready){
adc_ready = false;
//add ADC value to buffer
audioBuffer[bufferWriteIndex++]= adc_value;
if (bufferWriteIndex >= BUFFER_SIZE){
bufferWriteIndex =0; //wrap around to maintain circular buffer
}
bufferCount++;
//if buffer is half or completely full, write to flash
if (bufferCount >= PAGE_SIZE){
WriteBufferedDataToFlash();
}
//start the next ADC conversion
Read_ADC();
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!