Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Edge Interrupt with PLIB.h on pic32 problems

Status
Not open for further replies.

Ivan-Holm

Member level 5
Joined
Jun 3, 2010
Messages
84
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,288
Location
Denmark
Activity points
1,894
Hi we have some problem that this code
Code:
 [syntax=c]#include<p32xxxx.h>
#include<stdio.h>
#include <plib.h>

#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2

#define SYS_FREQ (80000000L)

#define CORE_TIMER_PERIOD       SYS_FREQ
//void ConfigInt0(EXT_INT_ENABLE |FALLING_EDGE_INT |EXT_INT_PRI_5 );
int Toggle_count;
int main()
{

void ConfigInt0(EXT_INT_ENABLE |FALLING_EDGE_INT | EXT_INT_PRI_5 );
TRISD =0x00000000;
PORTDbits.RD0 = 1;

while(1)
{
};
};


void __ISR(3, IPL5) CoreTimerHandler(void) //INT_EXTERNAL_0_VECTOR
{
   
//  .. things to do
	if (Toggle_count == 1) mPORTDToggleBits(BIT_0);
	if (Toggle_count == 2) mPORTDToggleBits(BIT_1);
	if (Toggle_count == 3) mPORTDToggleBits(BIT_2);
	Toggle_count ++;
	if (Toggle_count == 4) Toggle_count = 1;


	// .. Toggle the LED
 mPORTDToggleBits(BIT_0);

    // update the period
    UpdateCoreTimer(CORE_TIMER_PERIOD);

    // clear the interrupt flag
    mINT0ClearIntFlag();
while(1);
}[/syntax]
the error is in both void ConfigInt0 sentence when we have out-comment one at a time. we dont know if it is the right to do?. when we out-comment bouth sentence It's compile fine. but not when we want to enable external Interrupt.
whot is the right way or place to this void ConfigInt0 line
 

Leave out the void?

ConfigInt0(EXT_INT_ENABLE |FALLING_EDGE_INT | EXT_INT_PRI_5 );

This should call the function.

With the void, it is a function prototype declaration.
 
we have coded some interrupt is working in Mplab but it dos nog clered the bit 0 on port D

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[CODE]#include<p32xxxx.h>
#include<stdio.h>
#include <plib.h>
 
//#include <sys/attribs.h>
//#include <GenericTypeDefs.h>
//#include <stdarg.h>
 
#pragma config FPLLMUL = MUL_20, FPLLIDIV = DIV_2, FPLLODIV = DIV_1, FWDTEN = OFF
#pragma config POSCMOD = HS, FNOSC = PRIPLL, FPBDIV = DIV_2
 
#define SYS_FREQ (80000000L)
#define CORE_TIMER_PERIOD       SYS_FREQ
 
//ConfigInt0(EXT_INT_ENABLE | FALLING_EDGE_INT | EXT_INT_PRI_5 );
 
 
 
int main()
{
 
 
    // confugire Outputs
    mPORTDClearBits(BIT_0);         // Turn off RD 0 on startup.
    mPORTDSetPinsDigitalOut(BIT_0); // Make RD 0 as output.
 
    // set up the External 0 interrupt with a prioirty of 5 and zero sub-priority 0
    INTSetVectorPriority(INT_EXTERNAL_0_VECTOR, INT_PRIORITY_LEVEL_5);
    INTSetVectorSubPriority(INT_EXTERNAL_0_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
    INTClearFlag(INT_INT0);
    INTEnable (INT_INT0,INT_ENABLED);
    
    // configure for multi-vectored mode
    INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECTOR);
 
    // enable interrupts
    INTEnableInterrupts();
 
    while(1)
    {
        mPORTDClearBits(BIT_0);         // Turn off RD 0 on startup.
    }
 
 
    while(1)
    {
    }
};
 
                                            // IPL = Interrupt Priority Level (5) 
                                            // 3 = INT_INT0
void __ISR(3, IPL5) CoreTimerHandler(void)  // 3 = INT_EXTERNAL_0_VECTOR
{
int i;
    //  .. things to do
    // clear the interrupt flag
    mINT0ClearIntFlag();
 
    //Troggle LED RD0
    mPORTDToggleBits(BIT_0);
 
for(i=100000; i>=0; i--)
    {
    i--;
    }
 
}[/CODE]

 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top