完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我试图得到外部中断(使用外部中断3)代码工作在我的PIC24FJ64 GA00 6。我可以看到引脚低,但没有触发中断。使中断和设置优先权足以中断工作?我的代码是
以上来自于百度翻译 以下为原文 Hi, I am trying to get the external interrupt (using external interrupt 3 ) code to work on my pic24fj64ga006. I can see the pin going low but not triggering the interrupt. Is enabling the interrupt and setting priority enough for the interrupt to work ? my code is #include #include "p24fxxxx.h" #include "xc.h" #ifdef __PIC24FJ64GA006__ //Defined by MPLAB when using 24FJ256GB110 device // JTAG/Code Protect/Write Protect/Clip-on Emulation mode // Watchdog Timer/ICD pins select _CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx1) // Disable CLK switch and CLK monitor, OSCO or Fosc/2, HS oscillator, // Primary oscillator _CONFIG2(FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMOD_HS & FNOSC_PRIPLL) #endif // RB6 as SS for SPI slave MCU #define SPI_SS_TRIS TRISBbits.TRISB6 #define SPI_SS_PORT PORTBbits.RB6 unsigned short spiBufT[]={0x02,0x03,0x0d,0}; int Counter = 0; void InitClock() { CLKDIVbits.RCDIV=0; while(OSCCONbits.LOCK != 1) {}; } void SPI2Init(void) { //config SPI1 SPI2STATbits.SPIEN = 0; // disable SPI port SPI2STATbits.SPISIDL = 0; // Continue module operation in Idle mode SPI2BUF = 0; // clear SPI buffer IFS2bits.SPI2IF = 0; // clear interrupt flag IEC2bits.SPI2IE = 0; // disable interrupt SPI2CON1bits.DISSCK = 0; // Internal SPIx clock is enabled SPI2CON1bits.DISSDO = 0; // SDOx pin is controlled by the module SPI2CON1bits.MODE16 = 0; // set in 16-bit mode, clear in 8-bit mode SPI2CON1bits.SMP = 0; // Input data sampled at middle of data output time SPI2CON1bits.CKP = 0; // CKP and CKE is subject to change ... SPI2CON1bits.CKE = 0; // ... based on your communication mode. SPI2CON1bits.MSTEN = 1; // 1 = Master mode; 0 = Slave mode SPI2CON1bits.SPRE = 4; // Secondary Prescaler = 4:1 SPI2CON1bits.PPRE = 2; // Primary Prescaler = 4:1 SPI2CON2 = 0; // non-framed mode SPI_SS_PORT = 1; // ALL SPI_SS_PORT PINS ARE CLEARED SPI_SS_TRIS = 0; // set SS as output -RB6 SPI2STATbits.SPIEN = 1; // enable SPI port, clear status } unsigned short writeSPI2( unsigned short data ) { SPI2BUF = data; while(!SPI2STATbits.SPIRBF); // wait for transfer to complete return SPI2BUF; // read the received value } int main (void) { unsigned short i; InitClock(); SPI2Init(); SPI_SS_PORT = 0; //Enable interrupts... //INTCON1bits.NSTDIS = 1; // Disable nested interrupts INTCON2bits.INT3EP = 1; // Interrupt on positive edge of External Interrupt 3 IPC13bits.INT3IP = 001; // Priority level //IFS3bits.INT3IF = 1; // Interrupt req flag status IEC3bits.INT3IE = 1; // Enable interrupt while(1) { } SPI_SS_PORT = 1; return 0; } void __attribute__((__interrupt__, no_auto_psv)) _INT3Interrupt(void) { //clear interrupt flag IFS3bits.INT3IF = 0; int i; // SPI Read... Counter++; } |
|
相关推荐
4个回答
|
|
|
|
|
|
嗨,CinziaG,根据这个链接,HTTPS://UpVALTE.CON/UPN/D6F84CDE01E2CE9D/,不,它没有PPS。
以上来自于百度翻译 以下为原文 Hi CinziaG, As per this link https://upverter.com/upn/d6f84cde01e2ce9d/ , no it doesnt have PPS |
|
|
|
此外,如果PIN具有模拟能力,则需要将其转换为数字模式。
以上来自于百度翻译 以下为原文 Also, if the pin has analog capability, you need to switch it to digital mode. |
|
|
|
HI QHB,我使用HASIC3/PMCS2/IT3/RD10功能的PIN。请检查代码是否正确,以便我排除这种可能性。
以上来自于百度翻译 以下为原文 Hi qhb, The pin that I am using has IC3/PMCS2/INT3/RD10 functionalities. Could you please check if the code is correct so that I can rule out that possibility ? |
|
|
|
只有小组成员才能发言,加入小组>>
5244 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3209 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2260 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 12:53 , Processed in 1.301084 second(s), Total 83, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号