mr.man
Newbie level 6
- Joined
- Jan 17, 2013
- Messages
- 13
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,371
I have problem when debug this code using mikroC.........
unsigned char sin_table[158]={0,3,6,9,12,15,18,21,24,27,30,
33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,
96,99,102,105,107,110,113,116,119,122,125,127,130,133,136,138,
141,144,147,149,152,155,157,160,163,165,168,170,173,175,178,180,
183,185,188,190,193,195,197,200,202,204,207,209,211,214,216,218,
220,222,227,229,231,233,235,237,239,241,243,245,246,248,250,252,
254,255,257,259,261,262,264,266,267,269,270,272,273,275,276,277,
279,280,282,283,284,285,287,288,289,290,291,292,293,294,295,296,
297,298,299,300,301,302,303,304,304,305,306,306,307,307,308,308,
309,309,309,310,310,310,311,311,311,311,311,311,311,311,312};
unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
unsigned int TBL_temp;
unsigned char DUTY_CYCLE;
void interrupt(){
TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
if (TBL_POINTER_NEW == 312){
CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
}
DUTY_CYCLE = TBL_POINTER_NEW;
TBL_POINTER_NEW >>8;
CCPR1L = sin_table[DUTY_CYCLE];
TBL_POINTER_OLD = TBL_POINTER_NEW;
PIR1 = 0;
}
void main() {
SET_FREQ = 1;
TBL_POINTER_SHIFT = 0;
TBL_POINTER_NEW = 0;
TBL_POINTER_OLD = 0;
DUTY_CYCLE = 0;
PR2 = 312;
TRISC = 0x3F;
CCP1CON = 0x4C;
PIR1 = 0;
T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
while (PIR1 == 0);
PIR1 = 0;
TRISC = 0;
PIE1 = 0x02;
INTCON =0xC0;
while(1);
}
when it goes to the interrupt function, suppose TBL_POINTER_NEW = 1(0+1=1) but it show 256. Is it something wrong with this code. Thank you...
unsigned char sin_table[158]={0,3,6,9,12,15,18,21,24,27,30,
33,36,39,42,45,48,51,54,57,60,63,66,69,72,75,78,81,84,87,90,
96,99,102,105,107,110,113,116,119,122,125,127,130,133,136,138,
141,144,147,149,152,155,157,160,163,165,168,170,173,175,178,180,
183,185,188,190,193,195,197,200,202,204,207,209,211,214,216,218,
220,222,227,229,231,233,235,237,239,241,243,245,246,248,250,252,
254,255,257,259,261,262,264,266,267,269,270,272,273,275,276,277,
279,280,282,283,284,285,287,288,289,290,291,292,293,294,295,296,
297,298,299,300,301,302,303,304,304,305,306,306,307,307,308,308,
309,309,309,310,310,310,311,311,311,311,311,311,311,311,312};
unsigned int TBL_POINTER_NEW, TBL_POINTER_OLD, TBL_POINTER_SHIFT, SET_FREQ;
unsigned int TBL_temp;
unsigned char DUTY_CYCLE;
void interrupt(){
TBL_POINTER_NEW = TBL_POINTER_OLD + SET_FREQ;
if (TBL_POINTER_NEW == 312){
CCP1CON.P1M1 = ~CCP1CON.P1M1; //Reverse direction of full-bridge
}
DUTY_CYCLE = TBL_POINTER_NEW;
TBL_POINTER_NEW >>8;
CCPR1L = sin_table[DUTY_CYCLE];
TBL_POINTER_OLD = TBL_POINTER_NEW;
PIR1 = 0;
}
void main() {
SET_FREQ = 1;
TBL_POINTER_SHIFT = 0;
TBL_POINTER_NEW = 0;
TBL_POINTER_OLD = 0;
DUTY_CYCLE = 0;
PR2 = 312;
TRISC = 0x3F;
CCP1CON = 0x4C;
PIR1 = 0;
T2CON = 4; //TMR2 on, prescaler and postscaler 1:1
while (PIR1 == 0);
PIR1 = 0;
TRISC = 0;
PIE1 = 0x02;
INTCON =0xC0;
while(1);
}
when it goes to the interrupt function, suppose TBL_POINTER_NEW = 1(0+1=1) but it show 256. Is it something wrong with this code. Thank you...