• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: 中斷的時間太長?
#3
中級會員
中級會員


查看用戶資訊
謝謝Master大的指導
原來是定義的時候就有限制了

發表於: 2008/1/18 10:12
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 中斷的時間太長?
#2
資深會員
資深會員


查看用戶資訊
你原來Long_Conut的型態是unsigned char,只要改成unsigned int就可以了。

發表於: 2008/1/17 1:01
不要問我哪裡來,我只是個流浪天涯的工程師
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


中斷的時間太長?
#1
中級會員
中級會員


查看用戶資訊
各位大大好, 小弟現在在研究中斷程式的寫法, 並將W401的5-2練習改寫成以下的程式:

#include <p18f4550.h>
#include <timers.h>
#include <delays.h>
#include "P18F_LCD.h"


void isr_high(void);

volatile unsigned char Long_Count ;
volatile unsigned char Direct_LED ;
volatile unsigned char Dir_Count ;

void main(void)
{
TRISD=0x00;

RCONbits.IPEN=1;
IPR1bits.TMR2IP=1;
INTCONbits.GIEH=1;

ADCON0 = 0x01;
ADCON2 = 0x25;
ADCON1 |= 0x0F;

OpenI2C(MASTER, SLEW_OFF);
SSPADD = 59; // 100KHz and 24MHz

Long_Count=0;

PORTD = 0x0F;

/***********************************/
/* Interrupt Time */
/*(1/(24Mhz/4)) (16*10)(199+1)) = 5.3ms */
/***********************************/
OpenTimer2 ( TIMER_INT_ON & T2_PS_1_16
& _POST_1_10);

PR2 = 199;
while(1);
}

//************************************************
//* #pragma Interrupt Declarations *
//* *
//* Function: isr_high_direct *
//* - Direct execution to the actual *
//* high-priority interrupt code. *
//************************************************
#pragma code isrhighcode = 0x0008

void isr_high_direct(void)
{
_asm
goto isr_high
_endasm
}
#pragma code

//************************************************
//* Function: isr_high(void) *
//* High priority interrupt will *
//* - Received a serial data from RS-232 *
//* Save the received data to buffer Rec_Data*
//************************************************
#pragma interrupt isr_high

void isr_high(void)
{
PIR1bits.TMR2IF=0;

if (Long_Count <= 250) Long_Count++;
else
{
Long_Count=0;

PORTD=PORTD^0xFF;

}
}
#pragma code


預計讓high, low byte的LED每隔4秒交互亮, 可是當我更改Long_Conut超過250, 中斷程式就不會執行else裡面的程式, 請問這是因為我延遲的時間設的太久了嗎?

如果是, 我欲達到原程式設計目的, 我該怎麼修改?
Oscillator : HS : HS+PLL, USB-HS
DEMO Board : APP013
MCU : P18F4550
謝謝

發表於: 2008/1/16 18:38
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------