اطلاعیه

Collapse
No announcement yet.

راه اندازی وقفه psp در میکرو pic18f66k80

Collapse
X
 
  • فیلتر
  • زمان
  • Show
Clear All
new posts

    راه اندازی وقفه psp در میکرو pic18f66k80

    سلام اساتید گرامی
    برای یک پروژه مجبور به خواندن پورت D میکرو (PIC 18F66K80) از طریق وقفه PSP هستم
    تمامی تنظیمات را انجام دادم
    در حالت پولینگ مقدار رجیستر PSP_DATA درست تغییر می کند و بدون مشکل خوانده می شود
    اما با اینکه وقفه و زیر روال درست تعریف شده وقفه PSP اتفاق نمی افتد و به زیر روال PSP نمی رود
    به صورت دستی هم با یک کردن پرچم وقفه PSP به PSP می رود
    پس میکرو از لحاظ سخت افزاری مشکلی ندارد
    دوستان گرامی لطفا یاری فرمایید
    خیلی عجله ای هم هست
    تشکر

    دلیل: ادغام دو پست برای جلوگیری از اسپم

    #include <18F66K80.h>
    #device PASS_STRINGS = IN_RAM
    #device HIGH_INTS=TRUE
    #device ADC=8
    #fuses NOWDT // Watch Dog Timer
    #fuses HSH,NOPUT,NOBROWNOUT
    #fuses NOFCMEN,NOIESO,CPD
    #fuses NOMCLR, NODEBUG, NOSTVREN, PROTECT
    #fuses INTRC
    #use delay(clock=64000000,crystal=16000000,restart_wdt)
    #use rs232(UART1, baud=9600,parity=N,bits=8,stop=1,timeout=20,stream =PORT1)


    #priority psp
    #int_psp
    void psp_isr() {
    bitmem[90]=1;
    intmem[2]=psp_data;


    }
    int8 psptemp=0;


    void main() {


    setup_psp(PSP_ENABLED);
    enable_interrupts(GLOBAL);
    enable_interrupts(INT_PSP);






    while(TRUE)
    {


    if(psptemp!=psp_data){
    psptemp=psp_data;
    printf(psp_data);
    }
    }
    }

    #2
    پاسخ : راه اندازی وقفه psp در میکرو pic18f66k80

    کد:
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=include"]#include[/URL][COLOR=#28282B][FONT=Yekan] <18F66K80.h>[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=device"]#device[/URL][COLOR=#28282B][FONT=Yekan] PASS_STRINGS = IN_RAM[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=device"]#device[/URL][COLOR=#28282B][FONT=Yekan] HIGH_INTS=TRUE[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=device"]#device[/URL][COLOR=#28282B][FONT=Yekan] ADC=8[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=fuses"]#fuses[/URL][COLOR=#28282B][FONT=Yekan] NOWDT // Watch Dog Timer[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=fuses"]#fuses[/URL][COLOR=#28282B][FONT=Yekan] HSH,NOPUT,NOBROWNOUT[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=fuses"]#fuses[/URL][COLOR=#28282B][FONT=Yekan] NOFCMEN,NOIESO,CPD[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=fuses"]#fuses[/URL][COLOR=#28282B][FONT=Yekan] NOMCLR, NODEBUG, NOSTVREN, PROTECT[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=fuses"]#fuses[/URL][COLOR=#28282B][FONT=Yekan] INTRC[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=use"]#use[/URL][COLOR=#28282B][FONT=Yekan] delay(clock=64000000,crystal=16000000,restart_wdt)[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=use"]#use[/URL][COLOR=#28282B][FONT=Yekan] rs232(UART1, baud=9600,parity=N,bits=8,stop=1,timeout=20,stream =PORT1)[/FONT][/COLOR]
    
    
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=priority"]#priority[/URL][COLOR=#28282B][FONT=Yekan] psp[/FONT][/COLOR]
    [URL="https://www.eca.ir/forums/usertag.php?do=list&action=hash&hash=int_psp"]#int_psp[/URL][COLOR=#28282B][FONT=Yekan][/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]void psp_isr() {[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]bitmem[90]=1;[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]intmem[2]=psp_data;[/FONT][/COLOR]
    
    
    [COLOR=#28282B][FONT=Yekan]}[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]int8 psptemp=0;[/FONT][/COLOR]
    
    
    [COLOR=#28282B][FONT=Yekan]void main() {[/FONT][/COLOR]
    
    
    [COLOR=#28282B][FONT=Yekan]setup_psp(PSP_ENABLED);[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]enable_interrupts(GLOBAL);[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]enable_interrupts(INT_PSP);[/FONT][/COLOR]
    
    
    
    
    
    
    [COLOR=#28282B][FONT=Yekan]while(TRUE)[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]{[/FONT][/COLOR]
    
    
    [COLOR=#28282B][FONT=Yekan]if(psptemp!=psp_data){[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]psptemp=psp_data;[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]printf(psp_data);[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]}[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]}[/FONT][/COLOR]
    [COLOR=#28282B][FONT=Yekan]}[/FONT][/COLOR]

    دیدگاه

    لطفا صبر کنید...
    X