Andes Workshop

It is currently Fri Mar 29, 2024 11:41 pm

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: 使程式從頭開始執行的程式寫法
PostPosted: Thu Feb 09, 2012 4:51 pm 
Offline
User avatar

Joined: Fri Mar 04, 2011 9:36 pm
Posts: 500
跳回0的寫法有2種
(1) asm("j _start\n\t");
跳回_start

(2) asm("li\t $r0, #0 \n\t");
asm("jr $r0 \n\t");
跳回0開始執行。

我剛才用demo-int測試過,將code加在GPIO的ISR裡,按下GPIO,
可以讓程式從頭開始執行。
下面是測試程式
Attachment:
demo-int.7z [34.35 KiB]
Downloaded 869 times


節錄程式片斷:
void HW0_ISR()
{
puts("* Enter HW0 ISR with GPIO *\n");
outw(GPIO_BASE + GPIO_IC_OFFSET, 0xFFFFFFFF);

/* This service will take 6 secs */
unsigned int period;
period = 6 * (MB_PCLK / TICK_HZ);
outw(TM2_LOAD, period);
outw(TM2_CNTR, 0);
outw(TM_CR, (inw(TM_CR) | TM_CR_TM2ENA | TM_CR_TM2UP));
while (1) {
unsigned int tm2_cntr = inw(TM2_CNTR);
if (tm2_cntr > period)
break;
}
puts("* End of HW0 ISR it takes 6 secs *\n");
/* Cindy */
asm("li\t $r0, #0 \n\t");
asm("jr $r0 \n\t");

}


Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 25 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group