I have written the code for cs42l52 codec for keil mcbstm32f400 shown below,i am sure about the other part of my code but there is something wrong with the attached code which i am not able to figure out.I have written the register addresses using the datasheet.Please guide somewhat to correct the code or provide a sample codec program.
uint8_t CS42L52_BEEP_VOL;//=0x07;// uint8_t val uint8_t CS42L52_BEEP_FREQ; uint8_t CS42L52_BEEP_TONE_CTL; //uint8_t CS42L52_BEEP_VOL; //uint8_t reg note.pitch; //uint8_t val note.duration; //#define CS42L52_BEEP_VOL 0x1D; void Beep(noteInfo note ) { /* Beep off time 1.23s and volume 0dB */ //Codec_Write(CS42L52_BEEP_VOL, 0x07); Codec_Write(0x1D, 0x07); /* Set beep note and beep duration */ //Codec_Write(CS42L52_BEEP_FREQ,note.pitch | note.duration); //Codec_Write(CS42L52_BEEP_FREQ,G5 | ONE_SECOND ); Codec_Write(0x1C,G5 | ONE_SECOND ); /* play single beep */ //Codec_Write(CS42L52_BEEP_TONE_CTL, 0x40); Codec_Write(0x1F, 0x40); /* Disable beep */ //Codec_Write(CS42L52_BEEP_TONE_CTL, 0x00); Codec_Write(0x1F, 0x40); }
there is something wrong with the attached code which i am not able to figure out.
So it really didn't occur to you that maybe others, who haven't spent days writing, testing and debugging this code thoroughly, like you presumably did, might need a little more information about why you think "there is something wrong"?
I am getting confused with the values to write in the function due to which i think my code is not working, reading and understanding such complex datasheets and code is difficult at starting but I am willing to learn.Also example programs should be provided for such complex peripherals by keil as it becomes important to provide support for such boards.
due to which i think my code is not working
So let me ask again: how did you arrive at the conclusion it's not working?
I downloaded the code into flash(mcbstm32f400) ,the beep sound is not coming ,its not even printing on lcd after going into main.Even if I am writing wrong values to the codec registers, glcd should work.My code is compiling without any errors and glcd works fine.
int main (void) {
noteInfo note = {G5, 0x02}; uint8_t codecID; char buffer[128];
HAL_Init (); /* Init Hardware Abstraction Layer */ SystemClock_Config (); /* Config Clocks */
GLCD_Initialize(); GLCD_SetBackgroundColor (GLCD_COLOR_WHITE); GLCD_ClearScreen (); /* clear the GLCD */ GLCD_SetBackgroundColor (GLCD_COLOR_BLUE); GLCD_SetForegroundColor (GLCD_COLOR_WHITE); GLCD_SetFont (&GLCD_Font_16x24); GLCD_DrawString (0, 0*24, " CORTEX "); GLCD_DrawString (0, 1*24, " m4 "); setDisplay();
showStatus(codecInitialize()); //codecInitialize(); showStatus(readCodecChipID(&codecID)); sprintf(buffer, "Chip ID: 0x%x", codecID); GLCD_DrawString (1*16, 9*24, buffer); while (1) { Beep(note); /* Play the note */ wait_delay(500); /* pause */ } /* WHILE */ }
Refer the below link: file:///E:/Keil_v5.16/ARM/Pack/Keil/MDK-Middleware/7.8.0-dev18/Doc/USB/html/group__usbd__adc_functions.html
"My code is compiling without any errors and glcd works fine"
If, as you say, "its not even printing on lcd" - then how can you tell that the glcd "works fine"?
What debugging have you done?
Have you stepped the code in the debugger?
Have you checked that you are getting appropriate signals on the interface lines?
Do any of those GLCD_...() function calls return status results?
"My code is compiling without any errors"
That just shows that you have no syntax errors - it is no indication that your code will function.
The link is not opening ,also the link you provide seems invalid.
Yeah glcd is working fine because in my other codes it is functioning properly.
Have you checked that you are getting appropriate signals on the interface lines? I dont know how to do that,please share some reading material or link. I did some debugging ,it was moving line by line.I am learning how to use debug properly.
Do any of those GLCD_...() function calls return status results? yes
Use an oscilloscope or logic analyser.
The GLCD datasheet will show you what signals it requires.
Compare your working & non-working cases.
Always pay attention to function return results! Not only do they tell you when things have gone wrong - they also give you an indication of what has gone wrong.