Code: Select all
program ctcss_encoder02;
{ Declarations section }
const
ccode: array[1..50] of word = (61890,62010,62140,62260,62370,62480,62585,62690,62790,62885,62980,63050,63120,63200,63285,
63363,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,64617,64632);
procedure InitTimer1();
begin //Prescaler 1:1; TMR1 Preload = 61805; Actual Interrupt Time : 1,4924 ms
{T1CON := 0x01;
TMR1IF_bit := 0;
TMR1H := 0xF1;
TMR1L := 0x6D;
TMR1IE_bit := 1;}
T1CON := 1; // Timer1 settings
PIR1.TMR1IF := 0; // clear TMR1IF
TMR1H := 0xF1; // Initialize Timer1 register
TMR1L := 0x6D;
PIE1.TMR1IE := 1;
INTCON := 0xC0;
end;
procedure Interrupt();
begin
if (TMR1IF_bit) then
begin
TMR1IF_bit := 0;
TMR1H := Hi(ccode[portb]);
TMR1L := Lo(ccode[portb]);
//Enter your code here
porta.0:=1;
delay_us(200);
porta.0:=0;
end;
end;
begin
{ Main program }
TRISA := 0; // PORTA is output
PORTA := 0;
TRISB := 255;
//PORTB := 0xFF;
InitTimer1;
while TRUE do
begin
end;
end.
My problem is: this code works very well in Proteus simulator. When programming it into a real 16F628, it isn't works. The 16F628 doesn't do the interrupt (otherwise the microcontroller works well). I've written my code based on the Mikroelektronika's Timer calculator. The code seems to be good, just I can't find the error.
What could be the problem ? Thank you for any help.