Subject:
RE: 16F876 and interrupts
From:
"Ronald Mundell" ####@####.####
Date:
18 Jul 2002 19:19:28 -0000
Message-Id: <000f01c22e8e$19a1c0e0$02a410ac@mundell>
Ok
I am busy with an app that make use off an Int(int on change). If I compile
the code without includeing the int(comment out), it has enough memory, the
moment I include the int it will only use the 96 low bytes of memory. I have
included some of the code below. If any body has got an idea please help
Ronald
#pragma interrupt_level 1
static void interrupt isr(void)
//void interrupt isr(void)
{
GIE = 0;
if ( RBIF )
{
RBIF = 0;
Log();
}
GIE = 1;
}
void SetupInt ( void )
{
GIE = 0; // Disable all interrupts
RBPU = 0; // Enables PortB Pullup Resistors
PEIE = 1; // Enable all unmasked peripheral interrupts
RBIE = 1; // Enable PortB change Interrupt
GIE = 1; // Enable Global Interrupts
}
void Setup ( void )
{
PORTA = 0x00;
PORTB = 0x00;
PORTC = 0x00;
ADCON1 = 0x07; // 0b0000011x select PA as Digital I/O
TRISA = 0xF8; // 0b11111000;
TRISB = 0xFE; // 0b11111110;
TRISC = 0x98; // 0b10011000;
SetupRS232();
System_Test();
SetupInt();
DeviceAddHi = i2c_rtcread ( DEVICEADDRESS_HI );
DeviceAddLo = i2c_rtcread ( DEVICEADDRESS_LO );
DeviceAddress = DeviceAddHi;
DeviceAddress <<= 8;
DeviceAddress |= DeviceAddLo;
}
void main ( void )
{
DeviceAddress = 0;
Setup();
while ( 1 )
{
toggle ( SYSTEM_OK );
delay_ms ( 250 );
if ( !SYS_TEST ) // Menu
Menu();
}
else
len = scanf ( buffer, MAXLEN );
if ( buffer[0] == ':' )
{
clrscr();
gotoxy ( 10, 10 );
message ( "Welcome...." );
gotoxy ( 10, 11 );
puts ( buffer, len );
}
for ( len = 0; len < MaxChar; len++ )
{
buffer[len] = 0x00;
}
}
}
}
#pragma interrupt_level 1
void Log ( void )// reentrant
{
int ch;
hi_ch = (char *)&ch + 1;
lo_ch = (char *)&ch;
*hi_ch = i2c_rtcread ( HI_LOGPOS );
*lo_ch = i2c_rtcread ( LO_LOGPOS );
log.sec = i2c_rtcread ( ch++ );
log.min = i2c_rtcread ( ch++ );
log.hour = i2c_rtcread ( ch++ );
log.day = i2c_rtcread ( ch++ );
log.date = i2c_rtcread ( ch++ );
log.month = i2c_rtcread ( ch++ );
log.year = i2c_rtcread ( ch++ );
log.status = PORTB & 0xf0;
if ( ch >= 0 && ch <= RAM1 )
{
dev = 0;
}
else if ( ch >= RAM1 && ch <= RAM2 )
{
dev = 1;
}
else if ( ch >= RAM2 && ch <= RAM3 )
{
dev = 2;
}
else
{
dev = 3;
}
i2c_eewrite ( dev, ch++, log.sec );
i2c_eewrite ( dev, ch++, log.min );
i2c_eewrite ( dev, ch++, log.hour );
i2c_eewrite ( dev, ch++, log.day );
i2c_eewrite ( dev, ch++, log.date );
i2c_eewrite ( dev, ch++, log.month );
i2c_eewrite ( dev, ch++, log.year );
i2c_eewrite ( dev, ch++, log.status );
i2c_rtcwrite ( HI_LOGPOS, *hi_ch );
i2c_rtcwrite ( LO_LOGPOS, *lo_ch );
}
void Menu ( void )
{
clrscr();
gotoxy ( 10, 4 );
message ( "#######################################" );
gotoxy ( 10, 5 );
message ( "# Sure Park System Configuration Menu #" );
gotoxy ( 10, 6 );
message ( "#######################################" );
gotoxy ( 10, 7 );
message ( "# 1)..............Set Real Time Clock #" );
gotoxy ( 10, 8 );
message ( "# 2).............Test Real Time Clock #" );
gotoxy ( 10, 9 );
message ( "# 3)............Set Controller Number #" );
gotoxy ( 10, 10 );
message ( "# 4)......................View Logger #" );
gotoxy ( 10, 11 );
message ( "# 5).....................Reset Logger #" );
gotoxy ( 10, 12 );
message ( "# 0).............................Exit #" );
gotoxy ( 10, 13 );
message ( "# Bay: " );
L2BCD ( DeviceAddress );
message ( " ........Select an option #" );
gotoxy ( 10, 14 );
message ( "#######################################" );
ch1 = getchar();
switch ( ch1 )
{
case '0': // Exit
clrscr();
gotoxy ( 10, 10 );
message ( "# Remove Jumper 1, and press Enter #" );
ch1 = getchar();
clrscr();
break;
case '1': // Set RTC
SetRTC(); // werk
break;
case '2': // View RTC
ViewRTC(); // werk
break;
case '3': // Bay Number
clrscr();
gotoxy ( 10, 10 );
message ( "Controller Number: " );
L2BCD ( DeviceAddress );
gotoxy ( 10, 12 );
message ( "Do you whant to change (Y/N)\n" );
ch1 = getchar();
putchar ( ch1 );
if ( ch1 == 'Y' )
{
clrscr();
gotoxy ( 10, 12 );
message ( "Enter New Number (00000-65535): " );
ch1 = scanf ( buffer, 5 );
for ( ch1 = 0; ch1 < 5; ch1++ )
{
buffer[ch1] -= 0x30;
}
DeviceAddress = strtoi ( buffer );
DeviceAddLo = ( DeviceAddress ) & 0xFF;
DeviceAddHi = ( DeviceAddress >> 8 ) & 0xFF;
i2c_rtcwrite ( DEVICEADDRESS_HI, DeviceAddHi );
i2c_rtcwrite ( DEVICEADDRESS_LO, DeviceAddLo );
gotoxy ( 10, 13 );
message ( "New Number: " );
L2BCD ( DeviceAddress );
}
else
{
gotoxy ( 10, 13 );
message ( "Exiting...." );
}
gotoxy ( 10, 14 );
message ( "Press any key....." );
ch1 = getchar();
break;
case '4': // View Logger
clrscr();
ViewLog();
message ( "\nPress any key....." );
ch1 = getchar();
break;
case '5': // Reset Logger
clrscr();
ResetLog();
message ( "\nPress any key....." );
ch1 = getchar();
break;
default: break;
}
}
-----Original Message-----
From: Jorge Cabral ####@####.####
Sent: 18 July 2002 03:20
To: ####@####.####
Subject: Re: 16F876 and interrupts
Explain a bit better ......
Use an example and same source code!
Mig
----- Original Message -----
From: "Ronald Mundell" ####@####.####
To: ####@####.####
Sent: Wednesday, July 17, 2002 9:10 PM
Subject: 16F876 and interrupts
> Hi
>
> I am busy writing a program that make use of interrupts using the HITECH
> compiler. before I used interrupts I had no memory problem, after I
included
> interrupts the compiler suddenly complained about memory issues. If
somebody
> can help, please do
>
> Ronald
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
>