180 likes | 324 Views
SDRAM Load and Play. By Hernacki, Kevin ECE3551 Final Project 25 April 2008. Overview. Purpose Solution and Operation Problems Code Initialize.c ISR.c Main.c Talkthrough.h Results References. Purpose.
E N D
SDRAM Load and Play By Hernacki, Kevin ECE3551 Final Project 25 April 2008
Overview • Purpose • Solution and Operation • Problems • Code • Initialize.c • ISR.c • Main.c • Talkthrough.h • Results • References
Purpose • To use the knowledge learned in ECE-3551, to make a final project. The project is to 1: use the SDRAM as a storage device for a song, and then 2: to play it back, 3: to play it back at a faster speed, and 4: to play it back at a slower speed.
Solution and Operation • Press PF8 once: Load data into SDRAM and LED4 on. • Second press stops load, LED4 off, and pointer back to beginning. • Press PF9 once: Play data from SDRAM and LED5 on. • Second press stops play back, LED5 off, and pointer back to beginning. • Press PF10 once: Play data faster and LED6 on. • Second press stops play back, LED6 off, and pointer back to beginning. • Press PF11 once: Play data slower and LED7 on. • Second press stops play back, LED7 off, and pointer back to beginning.
Problems • The set-up, size, and the rate speed of the SDRAM. • Loading and unloading the SDRAM. • The Pointer for the SDRAM. • Controlling the pointer for the SDRAM to get fast and slow play.
Code; Initialize.c • Initializing the flags for the push buttons PF8 – PF11. void Init_Flags(void) { *pFIO_INEN = 0x0f00; //workaround for anomaly 05000311.(PF8 - PF11 enabled) *pFIO_DIR = 0x0000; *pFIO_EDGE = 0x0f00; *pFIO_MASKA_D = 0x0f00; } • Initializing the SDRAM and Registers on the board. //SDRAM Setup void Init_SDRAM(void) { if (*pEBIU_SDSTAT & SDRS) { //SDRAM Refresh Rate Control Register *pEBIU_SDRRC = 0x00000406; //SDRAM Memory Bank Control Register *pEBIU_SDBCTL = 0x00000025; //SDRAM Memory Global Control Register *pEBIU_SDGCTL = 0x0091998d; Buffl = pSDRAM_open; ssync(); } } //end Init_SDRAM
ISR.c Loading the SDRAM EX_INTERRUPT_HANDLER(Sport0_RX_ISR) { unsigned char led1; //Variable for LED4. unsigned char led2; //Variable for LED5. unsigned char led3; //Variable for LED6. unsigned char led4; //Variable for LED7. // confirm interrupt handling *pDMA1_IRQ_STATUS = 0x0001; if(openload==1) //If PF8=1 the data (song) is to be loaded into the SDRAM and LED4 on. { iChannel0LeftIn = iRxBuffer1[INTERNAL_ADC_L0]; //Data from DAC left to left channel-in. iChannel0RightIn = iRxBuffer1[INTERNAL_ADC_R0]; //Data from DAC right to right channel-in. iChannel0LeftOut = iChannel0LeftIn; //Data from left channel-in to left channel-out. iChannel0RightOut = iChannel0RightIn; //Data from right channel-in to right channel-out. iTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut; //Data from channel-out to DAC. iTxBuffer1[INTERNAL_DAC_R0] = iChannel0RightOut; //Data from channel-out to DAC. *Buffl++ = (short)(iChannel0LeftIn>>8); //Load data self-increment into SDRAM. // from channel-in right shift 8. led1 = 0x01; //Turn LED4 on. if(Buffl>pSDRAM_end) //If Buffl at pSDRAM_end stop value, stop loading and turn off LED4. { Buffl=pSDRAM_open; //Pointer Buffl to first space in storage SDRAM. led1=0x00; //LED4 off. openload=0; //Stop data load of SDRAM. } *pFlashA_PortB_Data = led1; //LED4 in used. } if(openload==2) //If PF8=2 the SDRAM load will stop, // LED4 off, and openload to 0. { *pFlashA_PortB_Data=0x00; //LED4 off. openload=0; //Openload reset to 0. }
IRS.c Play back from SDRAM. if(playload==1) //If PF9=1 the data (song) is to be played back from SDRAM and LED5 on. { led2=0x02; //LED5 on. ChannelLeftOut = *Buffl++; //Play data self-increment from SDRAM into channel-out. iChannel0LeftOut = ((int) ChannelLeftOut)<<8; //Channel-out to channel-out interger shift left 8. iTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut; //Channel-out to DAC left. iTxBuffer1[INTERNAL_DAC_R0] = iChannel0LeftOut; //Channel-out to DAC right. if(Buffl>pSDRAM_end) //If Buffl at pSDRAM_end stop value, // stop playing and turn off LED5. { Buffl=pSDRAM_open; //Pointer Buffl to first space in storage SDRAM. led2=0x00; //LED5 off. playload=0; //Stop data playing of SDRAM. } *pFlashA_PortB_Data = led2; //LED5 in used. } if(playload==2) //If PF9=2 the SDRAM play back will stop, // LED5 off, and playload reset to 0. { *pFlashA_PortB_Data=0x00; //LED5 off. playload=0; //Playback reset to 0. }
ISR.c Play back faster from SDRAM. if(fast==1) //If PF10=1 the data (song) is to be played back faster from SDRAM and LED6 on. { led3=0x04; //LED6 on. x =Buffl++; //Pointer address self-increment from SDRAM into x. ptrf=x*2; //Play only even addresses from SDRAM = to ptr. ChannelLeftOut = *ptrf++; //Play data self-increment from SDRAM into channel-out. iChannel0LeftOut = ((int) ChannelLeftOut)<<8; //Channel-out to channel-out interger shift left 8. iTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut; //Channel-out to DAC left. iTxBuffer1[INTERNAL_DAC_R0] = iChannel0LeftOut; //Channel-out to DAC right. if(Buffl>pSDRAM_end) //If Buffl at pSDRAM_end stop value, stop playing and turn off LED6. { Buffl=pSDRAM_open; //Pointer Buffl to first space in storage SDRAM. led3=0x00; //LED6 off. fast=0; //Stop data playing of SDRAM. } *pFlashA_PortB_Data = led3; //LED6 in used. } if(fast==2) //If PF10=2 the faster play back will stop, LED6 off, and fast reset to 0. { *pFlashA_PortB_Data=0x00; //LED6 off. fast=0; //Fast reset to 0. }
ISR.c Play back slower from SDRAM. if(slow==1) //If PF11=1 the data (song) is to be played back slower from SDRAM and LED7 on. { led4=0x08; //LED7 on. ptrs = Buffl+1000000; //Play 1000000 samples. if (a>1) //If a >1, is the counter variable for a one cycle count. { Buffl++; //On the second cycle the pointer get incremented. a=0; //The a is reset to 0. } ptrs = Buffl; //Buffl address value = ptrs. a++; //The a is incremented by one. ChannelLeftOut = *ptrs; //The data at the address is fed into channel-out. iChannel0LeftOut = ((int) ChannelLeftOut)<<8; //Channel-out to channel-out interger shift left 8. iTxBuffer1[INTERNAL_DAC_L0] = iChannel0LeftOut; //Channel-out to DAC left. iTxBuffer1[INTERNAL_DAC_R0] = iChannel0LeftOut; //Channel-out to DAC right. if(Buffl>pSDRAM_end) //If Buffl at pSDRAM_end stop value, stop playing and turn off LED6. { Buffl=pSDRAM_open; //Pointer Buffl to first space in storage SDRAM. led4=0x00; //LED6 off. fast=0; //Stop data playing of SDRAM. } *pFlashA_PortB_Data = led4; //LED7 in used. } if(slow==2) //If PF11=2 the slow play back will stop, // LED7 off, and slow reset to 0. { *pFlashA_PortB_Data=0x00; //LED7 off. slow=0; //Slow reset to 0. }
ISR.c FlagA EX_INTERRUPT_HANDLER(FlagA_ISR) { if(*pFIO_FLAG_C == 0x0100) //PF8 switch. { *pFIO_FLAG_C = 0x0100; //Confirm interrupt handling workaround for anomaly 05000311. openload++; //Openload variable, self-increment, load into SDRAM. if(openload==3) //If openload=2, stop loading data. openload=0; //PF8 toggled off from loading data (song) into SDRAM, LED4 off. Buffl=pSDRAM_open; //Buffl pointer set back to first space in SDRAM. } if (*pFIO_FLAG_C == 0x0200) //PF9 switch.. { *pFIO_FLAG_C = 0x0200; playload++; //Playload variable, self-increment, play data from SDRAM. if(playload==3) //If playload=2, stop playing data from SDRAM. playload =0; //PF9 toggled off from playing data (song) from SDRAM, LED5 off. Buffl=pSDRAM_open; //Buffl pointer set back to first space in SDRAM. }
ISR.c FlagA Continued if (*pFIO_FLAG_C == 0x0400) //PF10 switch. { *pFIO_FLAG_C = 0x0400; fast++; //fast variable, self-increment, play data from SDRAM. if(fast==3) //If fast=2, stop playing data from SDRAM. fast=0; //PF10 toggled off from playing data (song) from SDRAM, LED6 off. Buffl=pSDRAM_open; //Buffl pointer set back to first space in SDRAM. } if (*pFIO_FLAG_C == 0x0800) //PF11 switch. { *pFIO_FLAG_C = 0x0800; slow++; //Slow variable, self-increment, play data from SDRAM. if(slow==3) //If slow=2, stop playing data from SDRAM. slow=0; //PF11 toggled off from playing data (song) from SDRAM, LED7 off. Buffl=pSDRAM_open; //Buffl pointer set back to first space in SDRAM. }
Main.c //The *Buffl is a variable interger for the Buffl pointer. int *Buffl; // The ptr is a variable for pointer for fast. int *ptrf; // The ptr is a variable for pointer for slow. int *ptrs; //The openload is a variable for the PF8 to load the data (song) into SDRAM. int openload=0; //The playload is a variable interger for the PF9 to play the data (song) from SDRAM. int playload=0; //The fast is a variable interger for the PF10 to play the data (song) faster from SDRAM. int fast=0; //The slow is a variable interger for the PF11 to play the data (song) slower from SDRAM. int slow=0; //The x is a variable interger for the fast and slow equations. int x=0; //The a is a variable interger for the slow play back "for loop". int a=0; short ChannelLeftOut; short ChannelRightOut;
Talkthrough.h • Symbolic constants #define pSDRAM_open (unsigned int *)0x00000000 //SDRAM begining address for pointer. #define pSDRAM_end (unsigned int *)0x01FFFFFF //SDRAM end address for pointer. // two minutes and fifty-five seconds of storage. • Global variables void Init_SDRAM(void); extern short ChannelLeftOut; extern short ChannelRightOut extern int i; extern int *Buffl; extern int *ptrf; extern int *ptrs; extern int openload; extern int playload; extern int fast; extern int slow; extern int x; extern int a; extern short ChannelLeftOut; extern short ChannelRightOut; • Prototypes void Init_SDRAM(void);
Results • Pressing PF8 loads the data (song) into the SDRAM, LED4 comes on; it stops at the end of the SDRAM space/or second press, LED4 goes off, and the point goes back to beginning. • Pressing PF9 plays the data (song) back from the SDRAM exactly as it was played in, LED5 comes on; it stops at the end of the SDRAM space/or second press, LED5 goes off, and pointer goes back to beginning. • Pressing PF10 plays the data (song) back from the SDRAM at a faster speed, LED6 comes on; press the button a second time to stop, LED6 goes off, and pointer goes back to beginning. • Pressing PF11 plays the data (song) back from the SDRAM at slower speed, LED7 comes on; press the button a second time to stop, LED7 goes off, and pointer goes back to beginning.
References • Dr. Keputska’s web page • http://my.fit.edu/~vkeputska/ece3551/ • Dr. Kepuska’s class slides