simulation 18F4620

Status
Not open for further replies.

Mitt

New Member
#include <p18f4620.h>
#include <timers.h>
#include <portb.h>
int counter;



#pragma romdata CONFIG1H = 0x300001
const rom unsigned char config1H = 0b00000110; // HSPLL oscillator

#pragma romdata CONFIG2L = 0x300002
const rom unsigned char config2L = 0b00011111; // Brown-out Reset Enabled in hardware @ 2.0V, PWRTEN disabled

#pragma romdata CONFIG2H = 0x300003
const rom unsigned char config2H = 0b00010010; // HW WD disabled, 1:512 prescaler

#pragma romdata CONFIG3H = 0x300005
const rom unsigned char config3H = 0b10000000; // PORTB digital on RESET

#pragma romdata CONFIG4L = 0x300006
const rom unsigned char config4L = 0b10000001; // DEBUG disabled,
// XINST disabled
// LVP disabled
// STVREN enabled







// prototype section
void int0_isr (void); //Interrupts sevice rounting for External interrupts 0//
void EnableLowInterrupts (void);

/*
* For PIC18xxxx devices, the low interrupt vector is found at 000000018h.
* Change the default code section to the absolute code section named
* low_vector located at address 0x18.
*/
#pragma code low_vector=0x18
void low_interrupt (void)
{
/*
* Inline assembly that will jump to the ISR.
*/

if(INTCONbits.INT0IF == 1)
{
_asm GOTO int0_isr _endasm
}

}

/*
* Returns the compiler to the default code section.
*/
#pragma code

/*
* Specifies the function timer_isr as a low-priority interrupt service
* routine. This is required in order for the compiler to generate a
* RETFIE instruction instead of a RETURN instruction for the timer_isr
* function.
*/
#pragma interruptlow int0_isr

/*
* Define the timer_isr function. Notice that it does not take any
* parameters, and does not return anything (as required by ISRs).
*/

void int0_isr (void) // Interrupts sevrvice routine for Interrupts RB0(FALLING_EDGE_INT)//
{
INTCONbits.INT0IF = 0;

counter++;


}


void main (void)
{

RCONbits.IPEN=1;
INTCONbits.GIEL=1;

OpenRB0INT( PORTB_CHANGE_INT_ON & FALLING_EDGE_INT & PORTB_PULLUPS_ON);

while (1)
{

}

}

void EnableLowInterrupts (void)
{

}

Form this code,I want to count Pulse(Pull up resistor) and read a variable counter but I have have a problem about simlation process.
[img=https://images.temppic.com/19-02-2009/images_vertis/1235047728_0.11740200.bmp]
form picture I detect pulses at falling edge and use interrupts increase counter but when I watch form simulation process a variable counter doesn't increase. So I want to ask. Is code wrong or I use simulation process wrong.
Thank you.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…