kylemaes
Banned
Hey guys, So I cannot find out on the internet how to get this to work! IVE TRIED EVERYTHING!
I want it so when TMR0 rolls over it goes to an interrupt like Hi-Tech C... Not all this compilcated mess and if there is no way but the complicated #pragma stuff then please say how it is done.
Im also running at 48 mhz clock to let everyone know... This worked before! Just need to know where the interrupt handler is and stuff...
Here is my code:
I want it so when TMR0 rolls over it goes to an interrupt like Hi-Tech C... Not all this compilcated mess and if there is no way but the complicated #pragma stuff then please say how it is done.
Im also running at 48 mhz clock to let everyone know... This worked before! Just need to know where the interrupt handler is and stuff...
Here is my code:
Code:
#include <p18f2550.h>
#include "delays.h"
#pragma config PLLDIV = 1, CPUDIV = OSC1_PLL2, USBDIV = 1, FOSC = HS, FCMEN = OFF, IESO = OFF
#pragma config PWRT = ON, BOR = OFF, VREGEN = OFF, WDT = OFF, PBADEN = OFF, LPT1OSC = OFF, MCLRE = OFF
#pragma config STVREN = OFF, LVP = OFF, DEBUG = OFF
/*****************************************************************************************************************************/
#define E PORTAbits.RA5
#define RS PORTAbits.RA4
#define RW PORTAbits.RA3
char fare = 0;
char huns = 0;
char tens = 0;
char ones = 0;
char huns2 = 0;
char tens2 = 0;
char ones2 = 0;
char remain = 0;
char interruptnum = 0;
const char ScreenData[39] = {
0x41, //A 0
0x42, //B 1
0x43, //C 2
0x44, //D 3
0x45, //E 4
0x46, //F 5
0x47, //G 6
0x48, //H 7
0x49, //I 8
0x4A, //J 9
0x4B, //K 10
0x4C, //L 11 //CHARACTER DEFINITIONS!
0x4D, //M 12
0x4E, //N 13
0x4F, //O 14
0x50, //P 15
0x51, //Q 16
0x52, //R 17
0x53, //S 18
0x54, //T 19
0x55, //U 20
0x56, //V 21
0x57, //W 22
0x58, //X 23
0x59, //Y 24
0x5A, //Z 25
0x20, //SPACE 26
0x3A, //: 27
0x30, //0 28
0x31, //1 29
0x32, //2 30
0x33, //3 31
0x34, //4 32
0x35, //5 33
0x36, //6 34
0x37, //7 35
0x38, //8 36
0x39, //9 37
0x25 //% 38
};
void Busy_Flag()
{
RW = 1; //read mode
while(PORTBbits.RB7); //Loop until finished
RW=0; //default to write mode...
}
void Strobe_LCD()
{
E=1;
Delay1KTCYx(4);
E=0;
}
void Write_LCD(unsigned char d,unsigned char x) //USE "Write_LCD(tabledata,1=cap0=lowercase);" (IF number Cap selection must equal 0!)
{
char z = 0x00;
if(!x)
{
z=0x20;
}
TRISB=0x00;
PORTB=d+z;
Strobe_LCD();
Busy_Flag();
TRISB=0xFF;
}
void lcd_init()
{
Write_LCD(0x38,1);
Write_LCD(0x0C,1);
Write_LCD(0x01,1);
}
void AddressDisplay(unsigned char c)
{
Busy_Flag(); //check LCD ready
RW = 0; //write mode
RS=0; //command mode
PORTB=c; //place data on data port
TRISB = 0; //PORTB output
Strobe_LCD();
RS=1;
TRISB = 0xFF; //PORTB input
}
const char programnametext[16] = {
2,14,12,15,14,18,19,4,17,26,26,21,4,17,27,29
/*Co m p o s t e r V e r : 1*/
};
programname()
{
char a = 0;
char b;
char c;
Write_LCD(0x01,1);
RS = 1;
while(a != 16)
{
if((a==14) | (a==0) | (a==9) | (a==10) | (a==15) | (a==11)){c=1;}
Write_LCD(ScreenData[programnametext[a]],c);
c=0;
a++;
}
RS = 0;
}
/*****************************************************************************************************************************/
void main()
{
TRISA=0;
TRISB=0xFF;
TRISC=0;
ADCON0=0;
OSCTUNE=0x0F;
lcd_init();
programname();
/**************************/
INTCON=0b11100000;
T0CON=0b11000111;
/*************************/
while(1){}
}
#pragma interrupt foo
void foo(void)
{
//PWM DATA CATCH / TEMPERATURE **************************************//
if(interruptnum == 1)
{
fare=0; //TEMPERATURE SETUP ADC SUPPOSED TO BE ADRESL NOT 0!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
fare=fare*100;
fare=fare/255;
huns2=fare/100;
remain=fare-(huns2*100);
tens2=remain/10;
ones2=remain-(tens2*10);
}
//*******************+DISPLAY*************************//
if(interruptnum == 2)
{
RS=1;
AddressDisplay(0xC0); //FANSPEED
Write_LCD(ScreenData[5],1);
Write_LCD(ScreenData[0],0);
Write_LCD(ScreenData[13],0);
Write_LCD(ScreenData[27],1);
if(!huns){Write_LCD(ScreenData[26],1);}else{Write_LCD(ScreenData[28+huns],1);}
Write_LCD(ScreenData[28+tens],1);
Write_LCD(ScreenData[28+ones],1);
Write_LCD(ScreenData[38],1);
AddressDisplay(0x90);
Write_LCD(ScreenData[19],1);
Write_LCD(ScreenData[4],0);
Write_LCD(ScreenData[12],0);
Write_LCD(ScreenData[15],0);
Write_LCD(ScreenData[27],1);
if(!huns2){Write_LCD(ScreenData[26],1);}else{Write_LCD(ScreenData[28+huns2],1);} //FOR TEMPERATURE!
Write_LCD(ScreenData[28+tens2],1);
Write_LCD(ScreenData[28+ones2],1);
Write_LCD(ScreenData[26],1);
Write_LCD(ScreenData[3],0);
Write_LCD(ScreenData[4],0);
Write_LCD(ScreenData[6],0);
RS=0;
}
if(interruptnum == 3)
{
interruptnum = 0;
}
interruptnum++;
INTCONbits.TMR0IF = 0;
}