Other Parts Discussed in Thread: LM4819,
Hi,
Thank you guys for your kind support upto this point of time. I got so many solutions to my each problem that I thrown onto this forum.
I again come back with one more!
I am trying to integrate the buzzer to my TM4C123 tiva controller in the same way as done in the eval kit DK-TM4C129.
I am using the example code provided for TM4c129 for TM4c123 with minute changes & now now my code is error free.
But after so much of excercise I am not able to get the relevant sound through my buzzer, only hissing noise is coming.
Kindly find the implemented code as below & suggest any change in methodology:
int
main(void)
{
uint32_t ui32Temp, count;
uint32_t ui32Retcode, ui32NewKey, ui32OldKey;
tContext sContext;
unsigned long input,previous;
//
// Enable lazy stacking for interrupt handlers. This allows floating-point
// instructions to be used within interrupt handlers, but at the expense of
// extra stack usage.
//
ROM_FPULazyStackingEnable();
//
// Set the system clock to run at 50MHz from the PLL.
//
/*ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);
*/
g_ui32SysClock = SysCtlClockFreqSet((SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ), 50000000);
//
// Configure the required pins for USB operation.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
ROM_GPIOPinConfigure(GPIO_PG4_USB0EPEN);
ROM_GPIOPinTypeUSBDigital(GPIO_PORTG_BASE, GPIO_PIN_4);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOL);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTL_BASE, GPIO_PIN_6 | GPIO_PIN_7);
ROM_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOP);
ROM_GPIOPinConfigure(GPIO_PP2_T5CCP0);
ROM_GPIOPinTypeTimer(GPIO_PORTP_BASE, GPIO_PIN_2);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_1);
ROM_GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, 1);
//
// Configure SysTick for a 100Hz interrupt.
//
ROM_SysTickPeriodSet(SysCtlClockGet() / TICKS_PER_SECOND);
ROM_SysTickEnable();
ROM_SysTickIntEnable();
//
// Enable Interrupts
//
// ROM_IntMasterEnable();
//
// Initialize the display driver.
//
CFAL96x64x16Init();
//
// Initialize the buttons driver.
//
ButtonsInit();
//
// Initialize two offscreen displays and assign the palette. These
// buffers are used by the slide menu widget to allow animation effects.
//
GrOffScreen4BPPInit(&g_sOffscreenDisplayA, g_pui8OffscreenBufA, 96, 40);
GrOffScreen4BPPPaletteSet(&g_sOffscreenDisplayA, g_pui32Palette, 0,
NUM_PALETTE_ENTRIES);
GrOffScreen4BPPInit(&g_sOffscreenDisplayB, g_pui8OffscreenBufB, 96, 40);
GrOffScreen4BPPPaletteSet(&g_sOffscreenDisplayB, g_pui32Palette, 0,
NUM_PALETTE_ENTRIES);
//
// Add the compile-time defined widgets to the widget tree.
//
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sHeading);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sStatus);
WidgetAdd(WIDGET_ROOT, (tWidget *)&g_sFileMenuWidget);
//
// Initialize the status text.
//
strcpy(g_pcStatusText, "No Device");
//
// Issue the initial paint request to the widgets then immediately call
// the widget manager to process the paint message. This ensures that the
// display is drawn as quickly as possible and saves the delay we would
// otherwise experience if we processed the paint message after mounting
// and reading the SD card.
//
WidgetPaint(WIDGET_ROOT);
WidgetMessageQueueProcess();
//
// Determine whether or not an SD Card is installed. If not, print a
// warning and have the user install one and restart.
//
// ui32Retcode = disk_initialize(0);
ui32Retcode = RES_OK;
if(ui32Retcode != RES_OK)
{
g_pcStatusLines[0] = "No SD Card Found";
g_pcStatusLines[1] = "Please insert";
g_pcStatusLines[2] = "a card and";
g_pcStatusLines[3] = "reset the board.";
ShowStatusScreen(g_pcStatusLines, 4);
//return (1);
}
else
{
g_pcStatusLines[0] = "SD Card Found";
// ShowStatusScreen(g_pcStatusLines, 1);
// Mount the file system, using logical disk 0.
//
/* f_mount(0, &g_sFatFs);
if(!FileInit())
{
return(1);
}*/
}
//
//
// Not playing anything right now.
//
/*g_ui32Flags = 0;
g_ui32SysTickCount = 0;
g_ui32LastTick = 0;
g_ui32CurrentVolume = INITIAL_VOLUME_PERCENT;*/
// PP2/PP1 are used for the speaker output.
//
/*ROM_GPIOPinConfigure(GPIO_PP2_T5CCP0);
ROM_GPIOPinTypeTimer(GPIO_PORTP_BASE, GPIO_PIN_2);
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTP_BASE, GPIO_PIN_1);
ROM_GPIOPinWrite(GPIO_PORTP_BASE, GPIO_PIN_1, GPIO_PIN_1);*/
strcpy(g_pcStatusText, "Speaker configured");
//
//
//
// Configure the USB host output.
//
USBSoundInit(0, AudioEvent);
//
// Initialize audio streaming to stopped state.
//
/* StopAudio();
SoundVolumeSet(60000);
SoundInit(g_ui32SysClock);*/
SoundInit(g_ui32SysClock);
SoundVolumeSet(128);
// GenerateAudio(g_pi16AudioBuffer, AUDIO_SIZE / 2);
//SoundStart((int16_t *)g_pi16AudioBuffer, AUDIO_SIZE, 8000, SoundCallback);
strcpy(g_pcStatusText, "Speaker playing");
WidgetPaint(WIDGET_ROOT);
WidgetMessageQueueProcess();
//
// Default the old and new key to not pressed so that the first key press
// will be properly drawn on the keyboard.
//
ui32OldKey = NUM_WHITE_KEYS + NUM_BLACK_KEYS;
ui32NewKey = NUM_WHITE_KEYS + NUM_BLACK_KEYS;
/*Sound_Init(); // initialize SysTick timer and DAC
Piano_Init();*/
//
// Enter an (almost) infinite loop for reading and processing commands from
// the user.
//
while(1)
{
SoundStart((int16_t *)g_pi16AudioBuffer, AUDIO_SIZE, 8000, SoundCallback);
GenerateAudio(g_pi16AudioBuffer, AUDIO_SIZE / 2);
}