I have written the below function psc0_lpsc_enable() for spi0:
void PSC0_LPSC_Enable(unsigned int PD,unsigned int LPSC_num) {while((PSC0_PTSTAT & 0x01)!=0);// wait until GOSTAT[0]= 0;No transition in progress (*(volatile unsigned int *)(PSC0_MDCTL + 4*LPSC_num))=(*(volatile unsigned int *)(PSC0_MDCTL +4*LPSC_num)) | 0x03; //Next=3;Enable state PSC0_PTCMD = 0x1; //Go[0]=1;initiate transition while((PSC0_PTSTAT & (0x1<<PD))!=0);// wait until GOSTAT[0]= 0;No transition in progres & modules are safe in new states while((*(volatile unsigned int *)(PSC0_MDCTL +4*LPSC_num)& 0xf)!=0x03);} On calling the function PSC0_LPSC_Enable(0,4) for spi0, the execution gets into infinite loop at step: while((*(volatile unsigned int *)(PSC0_MDCTL +4*LPSC_num)& 0xf)!=0x03); So, i tried executing the gel script for this function by acessing Scripts=>experimenter=>PSC_ALL_ON_Experimenter in the code composer studio.In this case, the MDCTL4 & PTCMD regs were getting updated. So i tried modifying my function according to gel script as given below:
void
PSC0_LPSC_Enable(unsigned int PD, unsigned int LPSC_num) {
unsigned int j;
if( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) != 0x3 ) {
*(
unsigned int*) (PSC0_MDCTL+4*LPSC_num) = (*(unsigned int*) (PSC0_MDCTL+4*LPSC_num) & 0xFFFFFFE0) | 0x0003;
PSC0_PTCMD = 0x1<<PD;
j = 0;
/*Wait for power state transition to finish*/
while( (PSC0_PTSTAT & (0x1<<PD) ) !=0) {
if( j++ > 10 ) {
// GEL_TextOut("\tPSC0 Enable Transition Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
break;
} } j = 0;
while( (*(unsigned int*)(PSC0_MDSTAT+4 * LPSC_num) & 0x1F) !=0x3) {
if( j++ > 10 ) {
// GEL_TextOut("\tPSC0 Enable Verify Timeout on Domain %d, LPSC %d\n","Output",1,1,1,PD,LPSC_num);
break;}
}}}
But in this case also, the regs were not getting updated.Please suggest me on this.