_asm
// Initialize the stack pointer
[b] lfsr 1, _stack // Points here[/b]
lfsr 2, _stack
clrf TBLPTRU, 0 // 1st silicon doesn't do this on POR
bcf __FPFLAGS,RND,0 // Initialize rounding flag for floating point libs
_endasm
Hehehe Like code commenting, indentation, if left till the end, never gets done. Six months later you'll try to read your messy code and you'll kick yourself for not making it more readable. At this point your code is still small. Wait till it starts getting BIG. If you aren't organized you're lost.
i think something is wrong with my junebug buttons. I just slightly touch not press a button and it goes off. Eveything seems to work fine except that.
Only a tiny bit. You're still all over the place. Ah well, you'll improve with practice... maybe.
i think something is wrong with my junebug buttons. I just slightly touch not press a button and it goes off. Eveything seems to work fine except that.
Ok i found the floating pin and it was PORTB7 which calls a interrupt everytime i was my have over the board lol but when i set it in TRISB to 0 i get NO interrupts. I went over it like 20 times changing things but no luck plz any info.. thx
Code:
#pragma config OSC=INTIO2, WDT=OFF, LVP=OFF, DEBUG=ON
#include <p18f1320.h>
void InterruptHandlerHigh(void);
void InterruptVectorHigh(void);
void MyDelay(int x);
void MyFlash(int qTimes);
void main(void)
{
int count;
char countA = 0;
ADCON1 = 0; // make RA0 digital
TRISA = 0b10111110;
TRISB = 0x00000001;
LATB = 0;
INTCON = 0b11001000; //11011000;
INTCON2 = 0b11110101; //10000001
INTCON3 = 0b11001000;
while(1) // loop forever
{
LATA=0b00000001; // Turn LED on
MyDelay(200);
LATA=0b00000000; // Turn LED off
MyDelay(200);
countA = countA + 1;
//if (countA > 3) {
// MyFlash(3);
// countA = 0;
//}
}
}
// ----------------------------------------------------------
void MyDelay(int xD)
{
int countD = 0;
while (countD < xD)
{
countD = countD + 1;
}
}
// ----------------------------------------------------------
void MyFlash (int qTimes)
{
int x = qTimes;
while(x != 0)
{
TRISA = 0b10111110;
LATA = 0b00000001;
MyDelay(10);
LATA = 0b01000000;
MyDelay(10);
TRISA = 0b00111111;
LATA = 0b01000000;
MyDelay(10);
LATA = 0b10000000;
MyDelay(10);
TRISA = 0b01111110;
LATA = 0b10000000;
MyDelay(10);
LATA = 0b00000001;
MyDelay(10);
x--;
}
TRISA = 0b10111110;
}
//----------------------------------------------------------------------------
// High priority interrupt vector
#pragma code InterruptVectorHigh = 0x08
void InterruptVectorHigh (void)
{
_asm
goto InterruptHandlerHigh //jump to interrupt routine
_endasm
}
//----------------------------------------------------------------------------
// High priority interrupt routine
#pragma code
#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh () [b]//I have a breakpoint here[/b]
{
if (INTCONbits.RBIF)
{
INTCONbits.RBIF = 0; //clear interrupt flag
INTCONbits.INT0IF = 0;
MyFlash(1);
}
}
//----------------------------------------------------------------------------
Still a no go. Im going over every line but am dieing here lol I set trisb 7 and i get no breakpoints dont and i get that 1 breakpoint. I took the interrupt code from the C18 User Guide
New code