IRP - Message - How to resolve this
IRP - Message - How to resolve this
Hi,
I am getting the following warnings.
32 1511 IRP bit must be set manually for indirect access to 'output' variable clock-and-relays.c
Reading this forum and documents say, IRP bit must be set manually.
how is set in MikroC PRO, i mean what is the syntax or how can this problem be avoided.
Thank You
I am getting the following warnings.
32 1511 IRP bit must be set manually for indirect access to 'output' variable clock-and-relays.c
Reading this forum and documents say, IRP bit must be set manually.
how is set in MikroC PRO, i mean what is the syntax or how can this problem be avoided.
Thank You
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
Hi,
unsigned char output[16];
unsigned char x;
unsigned int y;
If I am using x = output[0]; this works fine
y = 0;
x = output[y]; this gives IRP message
Moreover
32 1511 IRP bit must be set manually for indirect access to 'output' variable clock-and-relays.c
32 is line number for the declaration of the variable output so how can I assign "IRP_bit =1" along with global variable declaration ?
Regards
unsigned char output[16];
unsigned char x;
unsigned int y;
If I am using x = output[0]; this works fine
y = 0;
x = output[y]; this gives IRP message
Moreover
32 1511 IRP bit must be set manually for indirect access to 'output' variable clock-and-relays.c
32 is line number for the declaration of the variable output so how can I assign "IRP_bit =1" along with global variable declaration ?
Regards
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
Hi, Please find the code, please help with the IRP message.
###############################################
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// Keypad Port and lines
#define KEYPAD_PORT PORTD // Select keypad port
#define KEYPAD_MENU F0 // Menu/Exit
#define KEYPAD_CURSOR F1 // Select/Cursor
#define KEYPAD_OK F2 // Ok
#define KEYPAD_INC F3 // Inc number
#define KEYPAD_DEC F4 // Dec number
#define KEYPAD_RESET F7 // Reset
unsigned char first;
unsigned char bSec, bMin, bStd, bDay, bMon, bYear, oldstate;
unsigned int uSec, uMin, uStd, uDay, uMon, uYear;
unsigned int cSec, cMin, cStd, cDay, cMon, cYear, timer_no;
unsigned int on[16], off[16];
unsigned char output[16];
extern void menu();
extern void Show_Menu(unsigned char Show_Menu);
extern void Show_Cursor( unsigned char Sign, unsigned char Show_Menu);
extern void IncDecSign( unsigned Sign, unsigned direct, unsigned Show_Menu);
extern void populate_output (unsigned int num);
extern unsigned short read_ds1307(unsigned char address);
extern void write_ds1307(unsigned char Addr, unsigned char Data);
extern void StoreToRTC(unsigned char t_or_d);
extern void display_time(void);
void Show_Menu(unsigned char Show_Menu)
{
Lcd_Cmd(_LCD_CLEAR);
if (Show_Menu == 0) // Main Menu
{
Lcd_Out( 1, 1, "Menu");
Lcd_Out( 1, 6, "Time");
Lcd_Out( 2, 6, "Date");
Lcd_Out( 3, 6, "Timers");
Lcd_Out( 4, 6, "Exit");
}
else if ((Show_Menu == 1) || (Show_Menu == 2)) // Change Time & Date Menu
{
if (Show_Menu == 1) // Change Time
{
Lcd_Out( 1, 1, "Set Time");
populate_output(uStd);
Lcd_out (1, 13, output);
Lcd_out (1, 15, ":");
populate_output(uMin);
Lcd_out (1, 16, output);
Lcd_out (1, 18, ":");
populate_output(uSec);
Lcd_out (1, 19, output);
}
else if (Show_Menu == 2) // Change Date
{
Lcd_Out( 1, 1, "Set Date");
populate_output(uDay);
Lcd_out (1, 13, output);
Lcd_out (1, 15, "/");
populate_output(uMon);
Lcd_out (1, 16, output);
Lcd_out (1, 18, "/");
populate_output(uYear);
Lcd_out (1, 19, output);
}
Lcd_Out( 3, 6, "Save");
Lcd_Out( 4, 6, "Exit");
}
else if (Show_Menu == 3) // Change Timers
{
Lcd_Out( 1, 2, "Set");
Lcd_Out( 2, 1, "Timer");
populate_output(timer_no);
Lcd_Out( 2, 7, output);
Lcd_Out( 2, 11, "On");
populate_output(on[timer_no-1]);
Lcd_Out( 2, 14, output);
Lcd_Out( 2, 16, ":");
populate_output(on[timer_no]);
Lcd_Out( 2, 17, output);
Lcd_Out( 3, 10,"OFF 00:00");
}
}
void menu( void)
{
unsigned char Sig;
unsigned char Which_Menu;
Sig=0;
Which_Menu=0;
// intialize comparators - added shan
cStd=0;cMin=0;cSec=0;
cDay=0;cMon=0;cYear=0;
Show_Menu( Which_Menu);
Show_Cursor( Sig, Which_Menu);
// Delay_ms( 250);
do
{
// Move Cursor
if( KEYPAD_PORT.KEYPAD_CURSOR == 0) {
delay_ms( 100);
Sig++;
if (Which_Menu == 0)
{
if( Sig > 3)
Sig = 0;
}
if ( (Which_Menu == 1) || (Which_Menu == 2) )
{
if( Sig > 4)
Sig = 0;
}
Show_Cursor( Sig, Which_Menu);
};
// Menu Option Selected - OK Key Pressed
if( KEYPAD_PORT.KEYPAD_OK == 0)
{
delay_ms( 100);
if ( (Which_Menu == 0) && (Sig == 3) )
break;
else if ( (Which_Menu == 0) && (Sig == 0) ) // call time menu
{
Which_menu = 1;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( (Which_Menu == 0) && (Sig == 1) ) // call Date menu
{
Which_Menu = 2;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( (Which_Menu == 0) && (Sig == 2) ) // call Timer menu
{
Which_Menu = 3;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( ((Which_Menu == 1) || (Which_Menu == 2)) && (Sig == 4) )
{
// Exit to Main Menu
Which_Menu = 0;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( ((Which_Menu == 1) || (Which_Menu == 2)) && (Sig == 3) )
{
// Save Time to RTC
StoreToRTC(Which_Menu);
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
};
// Increment
if( KEYPAD_PORT.KEYPAD_INC == 0) {
delay_ms( 100);
IncDecSign( Sig, 0, Which_Menu);
Show_Cursor( Sig, Which_Menu);
};
// Decrement
if( KEYPAD_PORT.KEYPAD_DEC == 0) {
delay_ms( 100);
IncDecSign( Sig, 1, Which_Menu);
Show_Cursor( Sig, Which_Menu);
};
Delay_ms( 100);
} while( 1);
// Refresh Display
Lcd_Cmd (_LCD_CLEAR);
Lcd_Cmd (_LCD_CURSOR_OFF);
}
void Show_Cursor( unsigned char Sign, unsigned char Show_Menu)
{
unsigned int k;
if (Show_Menu == 0)
{
switch( Sign)
{
case 0:
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 1:
Lcd_Cmd(_LCD_SECOND_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 2:
Lcd_Cmd(_LCD_THIRD_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 3:
Lcd_Cmd(_LCD_FOURTH_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
else if ((Show_Menu == 1) || (Show_Menu == 2))
{
switch( Sign)
{
case 0:
if (Show_Menu == 1)
{
uStd=(unsigned)bStd;
populate_output(uStd);
}
else if (Show_Menu == 2)
{
uDay=(unsigned)bDay;
populate_output(uDay);
}
Lcd_out (1, 13, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<14;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 1:
if (Show_Menu == 1)
{
uMin = (unsigned)bMin;
populate_output(uMin);
}
else if (Show_Menu == 2)
{
uMon=(unsigned)bMon;
populate_output(uMon);
}
Lcd_out (1, 16, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<17;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 2:
if (Show_Menu == 1)
{
uSec=(unsigned)bSec;
populate_output(uSec);
}
else if (Show_Menu == 2)
{
uYear=(unsigned)bYear;
populate_output(uYear);
}
Lcd_out (1, 19, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<20;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 3:
Lcd_Cmd(_LCD_THIRD_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 4:
Lcd_Cmd(_LCD_FOURTH_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
else if (Show_Menu == 3) // Timer Menu
{
switch( Sign)
{
case 0:
populate_output(timer_no);
Lcd_Out( 2, 7, output);
Lcd_Cmd(_LCD_SECOND_ROW);
for (k=1;k<8;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
}
void IncDecSign( unsigned Sign, unsigned direct, unsigned Show_Menu)
{
if (Show_Menu == 1) // Time Menu
{
switch( Sign)
{
case 0: if( !direct)
{
bStd++;
if( bStd > 23)
bStd = 23;
} else {
if( bStd > 0)
bStd--;
};
uStd = (unsigned int)bStd;
break;
case 1: if( !direct)
{
bMin++;
if( bMin > 59)
bMin = 59;
} else {
if( bMin > 0)
bMin--;
};
uMin = (unsigned int)bMin;
break;
case 2: if( !direct)
{
bSec++;
if( bSec > 59)
bSec = 59;
} else {
if( bSec > 0)
bSec--;
};
uSec = (unsigned int)bSec;
break;
}
}
else if (Show_Menu == 2) // Date Menu
{
switch( Sign)
{
case 0: if( !direct)
{
bDay++;
if( bDay > 31)
bDay = 31;
} else {
if( bDay > 0)
bDay--;
};
uDay = (unsigned int)bDay;
break;
case 1: if( !direct)
{
bMon++;
if( bMon > 12)
bMon = 12;
} else {
if( bMon > 0)
bMon--;
};
uMon = (unsigned int)bMon;
break;
case 2: if( !direct)
{
bYear++;
if( bYear > 99)
bYear = 99;
} else {
if( bYear > 0)
bYear--;
};
uYear = (unsigned int)bYear;
break;
};
}
else if (Show_Menu == 3) // Timer Menu
{
switch( Sign)
{
case 0: if( !direct)
{
timer_no++;
if( timer_no > 8)
timer_no = 8;
} else {
if( timer_no > 1)
timer_no--;
};
break;
}
}
}
void populate_output (unsigned int num)
{
output [0] = num/10 + 48;
output [1] = num%10 + 48;
return;
}
void main( void)
{
TRISD = 0b10011111;
PORTB = 0x00;
TRISC = 0x00;
PORTC = 0b00;
TRISD = 0xFF;
PORTD = 0xFF;
TRISE = 0x00;
PORTE = 0x00;
ADCON1 = 7; // disable analog inputs
TRISC.F3 = 1;
TRISC.F4 = 1;
first = 'Y';
timer_no=1;
on[0]=10; on[1]=30;
Delay_ms (2000);
I2C1_Init (100000); //DS1307 I2C is running at 100KHz
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn off cursor
Lcd_Out( 1, 1, " Initalizing Timer ");
Delay_ms( 1000);
Lcd_Cmd (_LCD_CLEAR);
do
{
Delay_ms (100);
display_time();
// Menu key pressed?
////////////////////
if( KEYPAD_PORT.KEYPAD_MENU == 0) {
delay_ms( 250);
menu();
} else if( KEYPAD_PORT.KEYPAD_RESET == 0) {
delay_ms( 250);
};
} while(1);
}
unsigned short read_ds1307(unsigned char address)
{
unsigned char Data;
I2C1_Start();
I2C1_Wr(0xd0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C1_Wr(address);
I2C1_Repeated_Start();
I2C1_Wr(0xd1); //0x68 followed by 1 --> 0xD1
Data=I2C1_Rd(0);
I2C1_Stop();
return(Data);
}
void write_ds1307(unsigned char Addr, unsigned char Data)
{
I2C1_Start(); // Issue I2C start signal
I2C1_Wr(0xd0); // Send hardware address for writting
I2C1_Wr(Addr); // Send low byte of the data address
I2C1_Wr(Data); // Send the data
I2C1_Stop(); // Free the bus
return;
}
void StoreToRTC(unsigned char t_or_d)
{
if (t_or_d == 1)
{
bSec = (((bSec / 10) << 4) & 0xF0) + ((bSec-(bSec / 10) * 10) & 0b00001111);
write_ds1307( 0x00, bSec);
bMin = (((bMin / 10) << 4) & 0xF0) + ((bMin-(bMin / 10) * 10) & 0b00001111);
write_ds1307( 0x01, bMin);
bStd = (((bStd / 10) << 4) & 0xF0) + ((bStd-(bStd / 10) * 10) & 0b00001111);
write_ds1307( 0x02, bStd);
}
else if (t_or_d == 2)
{
bDay = (((bDay / 10) << 4) & 0x30) + ((bDay-(bDay / 10) * 10) & 0b00001111);
write_ds1307( 0x04, bDay);
bMon = (((bMon / 10) << 4) & 0x10) + ((bMon-(bMon / 10) * 10) & 0b00001111);
write_ds1307( 0x05, bMon);
bYear = (((bYear / 10) << 4) & 0xF0) + ((bYear-(bYear / 10) * 10) & 0b00001111);
write_ds1307( 0x06, bYear);
}
delay_ms( 2000);
return;
}
void display_time(void)
{
bSec=read_ds1307(0x00); // read second
bSec = ((bSec & 0xF0) >> 4)*10 + (bSec & 0b00001111);
uSec = (unsigned int)bSec;
bMin=read_ds1307(0x01); // read minute
bMin = ((bMin & 0xF0) >> 4)*10 + (bMin & 0b00001111);
uMin = (unsigned int)bMin;
bStd=read_ds1307(0x02); // read hour
bStd = ((bStd & 0x30) >> 4)*10 + (bStd & 0b00001111);
uStd = (unsigned int)bStd;
bDay=read_ds1307(0x04); // read date
bDay = ((bDay & 0x30) >> 4)*10 + (bDay & 0b00001111);
uDay = (unsigned int)bDay;
bMon=read_ds1307(0x05); // read month
bMon = ((bMon & 0x10) >> 4)*10 + (bMon & 0b00001111);
uMon = (unsigned int)bMon;
bYear=read_ds1307(0x06); // read year
bYear = ((bYear & 0xF0)>> 4)*10 + (bYear & 0b00001111);
uYear = (unsigned int)bYear;
if ( (uStd != cStd) || (first == 'Y') )
{
cStd = uStd;
populate_output(uStd);
Lcd_out (1, 13, output);
Lcd_out (1, 15, ":");
}
if ( (uMin != cMin) || (first == 'Y') )
{
cMin = uMin;
populate_output(uMin);
Lcd_out (1, 16, output);
Lcd_out (1, 18, ":");
}
if ( (uSec != cSec) || (first == 'Y') )
{
cSec = uSec;
populate_output(uSec);
Lcd_out (1, 19, output);
}
if ( (uDay != cDay) || (first == 'Y') )
{
cDay = uDay;
populate_output(uDay);
Lcd_out (2, 13, output);
Lcd_out (2, 15, "/");
}
if ( (uMon != cMon) || (first == 'Y') )
{
cMon = uMon;
populate_output(uMon);
Lcd_out (2, 16, output);
Lcd_out (2, 18, "/");
}
if ( (uYear != cYear) || (first == 'Y') )
{
cYear = uYear;
populate_output(uYear);
Lcd_out (2, 19, output);
}
first = 'N';
return;
}
###############################################
// LCD module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
// Keypad Port and lines
#define KEYPAD_PORT PORTD // Select keypad port
#define KEYPAD_MENU F0 // Menu/Exit
#define KEYPAD_CURSOR F1 // Select/Cursor
#define KEYPAD_OK F2 // Ok
#define KEYPAD_INC F3 // Inc number
#define KEYPAD_DEC F4 // Dec number
#define KEYPAD_RESET F7 // Reset
unsigned char first;
unsigned char bSec, bMin, bStd, bDay, bMon, bYear, oldstate;
unsigned int uSec, uMin, uStd, uDay, uMon, uYear;
unsigned int cSec, cMin, cStd, cDay, cMon, cYear, timer_no;
unsigned int on[16], off[16];
unsigned char output[16];
extern void menu();
extern void Show_Menu(unsigned char Show_Menu);
extern void Show_Cursor( unsigned char Sign, unsigned char Show_Menu);
extern void IncDecSign( unsigned Sign, unsigned direct, unsigned Show_Menu);
extern void populate_output (unsigned int num);
extern unsigned short read_ds1307(unsigned char address);
extern void write_ds1307(unsigned char Addr, unsigned char Data);
extern void StoreToRTC(unsigned char t_or_d);
extern void display_time(void);
void Show_Menu(unsigned char Show_Menu)
{
Lcd_Cmd(_LCD_CLEAR);
if (Show_Menu == 0) // Main Menu
{
Lcd_Out( 1, 1, "Menu");
Lcd_Out( 1, 6, "Time");
Lcd_Out( 2, 6, "Date");
Lcd_Out( 3, 6, "Timers");
Lcd_Out( 4, 6, "Exit");
}
else if ((Show_Menu == 1) || (Show_Menu == 2)) // Change Time & Date Menu
{
if (Show_Menu == 1) // Change Time
{
Lcd_Out( 1, 1, "Set Time");
populate_output(uStd);
Lcd_out (1, 13, output);
Lcd_out (1, 15, ":");
populate_output(uMin);
Lcd_out (1, 16, output);
Lcd_out (1, 18, ":");
populate_output(uSec);
Lcd_out (1, 19, output);
}
else if (Show_Menu == 2) // Change Date
{
Lcd_Out( 1, 1, "Set Date");
populate_output(uDay);
Lcd_out (1, 13, output);
Lcd_out (1, 15, "/");
populate_output(uMon);
Lcd_out (1, 16, output);
Lcd_out (1, 18, "/");
populate_output(uYear);
Lcd_out (1, 19, output);
}
Lcd_Out( 3, 6, "Save");
Lcd_Out( 4, 6, "Exit");
}
else if (Show_Menu == 3) // Change Timers
{
Lcd_Out( 1, 2, "Set");
Lcd_Out( 2, 1, "Timer");
populate_output(timer_no);
Lcd_Out( 2, 7, output);
Lcd_Out( 2, 11, "On");
populate_output(on[timer_no-1]);
Lcd_Out( 2, 14, output);
Lcd_Out( 2, 16, ":");
populate_output(on[timer_no]);
Lcd_Out( 2, 17, output);
Lcd_Out( 3, 10,"OFF 00:00");
}
}
void menu( void)
{
unsigned char Sig;
unsigned char Which_Menu;
Sig=0;
Which_Menu=0;
// intialize comparators - added shan
cStd=0;cMin=0;cSec=0;
cDay=0;cMon=0;cYear=0;
Show_Menu( Which_Menu);
Show_Cursor( Sig, Which_Menu);
// Delay_ms( 250);
do
{
// Move Cursor
if( KEYPAD_PORT.KEYPAD_CURSOR == 0) {
delay_ms( 100);
Sig++;
if (Which_Menu == 0)
{
if( Sig > 3)
Sig = 0;
}
if ( (Which_Menu == 1) || (Which_Menu == 2) )
{
if( Sig > 4)
Sig = 0;
}
Show_Cursor( Sig, Which_Menu);
};
// Menu Option Selected - OK Key Pressed
if( KEYPAD_PORT.KEYPAD_OK == 0)
{
delay_ms( 100);
if ( (Which_Menu == 0) && (Sig == 3) )
break;
else if ( (Which_Menu == 0) && (Sig == 0) ) // call time menu
{
Which_menu = 1;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( (Which_Menu == 0) && (Sig == 1) ) // call Date menu
{
Which_Menu = 2;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( (Which_Menu == 0) && (Sig == 2) ) // call Timer menu
{
Which_Menu = 3;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( ((Which_Menu == 1) || (Which_Menu == 2)) && (Sig == 4) )
{
// Exit to Main Menu
Which_Menu = 0;
Sig = 0;
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
else if ( ((Which_Menu == 1) || (Which_Menu == 2)) && (Sig == 3) )
{
// Save Time to RTC
StoreToRTC(Which_Menu);
Show_Menu(Which_Menu);
Show_Cursor( Sig, Which_Menu);
}
};
// Increment
if( KEYPAD_PORT.KEYPAD_INC == 0) {
delay_ms( 100);
IncDecSign( Sig, 0, Which_Menu);
Show_Cursor( Sig, Which_Menu);
};
// Decrement
if( KEYPAD_PORT.KEYPAD_DEC == 0) {
delay_ms( 100);
IncDecSign( Sig, 1, Which_Menu);
Show_Cursor( Sig, Which_Menu);
};
Delay_ms( 100);
} while( 1);
// Refresh Display
Lcd_Cmd (_LCD_CLEAR);
Lcd_Cmd (_LCD_CURSOR_OFF);
}
void Show_Cursor( unsigned char Sign, unsigned char Show_Menu)
{
unsigned int k;
if (Show_Menu == 0)
{
switch( Sign)
{
case 0:
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 1:
Lcd_Cmd(_LCD_SECOND_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 2:
Lcd_Cmd(_LCD_THIRD_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 3:
Lcd_Cmd(_LCD_FOURTH_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
else if ((Show_Menu == 1) || (Show_Menu == 2))
{
switch( Sign)
{
case 0:
if (Show_Menu == 1)
{
uStd=(unsigned)bStd;
populate_output(uStd);
}
else if (Show_Menu == 2)
{
uDay=(unsigned)bDay;
populate_output(uDay);
}
Lcd_out (1, 13, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<14;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 1:
if (Show_Menu == 1)
{
uMin = (unsigned)bMin;
populate_output(uMin);
}
else if (Show_Menu == 2)
{
uMon=(unsigned)bMon;
populate_output(uMon);
}
Lcd_out (1, 16, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<17;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 2:
if (Show_Menu == 1)
{
uSec=(unsigned)bSec;
populate_output(uSec);
}
else if (Show_Menu == 2)
{
uYear=(unsigned)bYear;
populate_output(uYear);
}
Lcd_out (1, 19, output);
Lcd_Cmd(_LCD_FIRST_ROW);
for (k=1;k<20;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 3:
Lcd_Cmd(_LCD_THIRD_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
case 4:
Lcd_Cmd(_LCD_FOURTH_ROW);
for (k=1;k<6;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
else if (Show_Menu == 3) // Timer Menu
{
switch( Sign)
{
case 0:
populate_output(timer_no);
Lcd_Out( 2, 7, output);
Lcd_Cmd(_LCD_SECOND_ROW);
for (k=1;k<8;k++)
Lcd_Cmd(_LCD_MOVE_CURSOR_RIGHT);
Lcd_Cmd(_LCD_BLINK_CURSOR_ON);
break;
};
}
}
void IncDecSign( unsigned Sign, unsigned direct, unsigned Show_Menu)
{
if (Show_Menu == 1) // Time Menu
{
switch( Sign)
{
case 0: if( !direct)
{
bStd++;
if( bStd > 23)
bStd = 23;
} else {
if( bStd > 0)
bStd--;
};
uStd = (unsigned int)bStd;
break;
case 1: if( !direct)
{
bMin++;
if( bMin > 59)
bMin = 59;
} else {
if( bMin > 0)
bMin--;
};
uMin = (unsigned int)bMin;
break;
case 2: if( !direct)
{
bSec++;
if( bSec > 59)
bSec = 59;
} else {
if( bSec > 0)
bSec--;
};
uSec = (unsigned int)bSec;
break;
}
}
else if (Show_Menu == 2) // Date Menu
{
switch( Sign)
{
case 0: if( !direct)
{
bDay++;
if( bDay > 31)
bDay = 31;
} else {
if( bDay > 0)
bDay--;
};
uDay = (unsigned int)bDay;
break;
case 1: if( !direct)
{
bMon++;
if( bMon > 12)
bMon = 12;
} else {
if( bMon > 0)
bMon--;
};
uMon = (unsigned int)bMon;
break;
case 2: if( !direct)
{
bYear++;
if( bYear > 99)
bYear = 99;
} else {
if( bYear > 0)
bYear--;
};
uYear = (unsigned int)bYear;
break;
};
}
else if (Show_Menu == 3) // Timer Menu
{
switch( Sign)
{
case 0: if( !direct)
{
timer_no++;
if( timer_no > 8)
timer_no = 8;
} else {
if( timer_no > 1)
timer_no--;
};
break;
}
}
}
void populate_output (unsigned int num)
{
output [0] = num/10 + 48;
output [1] = num%10 + 48;
return;
}
void main( void)
{
TRISD = 0b10011111;
PORTB = 0x00;
TRISC = 0x00;
PORTC = 0b00;
TRISD = 0xFF;
PORTD = 0xFF;
TRISE = 0x00;
PORTE = 0x00;
ADCON1 = 7; // disable analog inputs
TRISC.F3 = 1;
TRISC.F4 = 1;
first = 'Y';
timer_no=1;
on[0]=10; on[1]=30;
Delay_ms (2000);
I2C1_Init (100000); //DS1307 I2C is running at 100KHz
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn off cursor
Lcd_Out( 1, 1, " Initalizing Timer ");
Delay_ms( 1000);
Lcd_Cmd (_LCD_CLEAR);
do
{
Delay_ms (100);
display_time();
// Menu key pressed?
////////////////////
if( KEYPAD_PORT.KEYPAD_MENU == 0) {
delay_ms( 250);
menu();
} else if( KEYPAD_PORT.KEYPAD_RESET == 0) {
delay_ms( 250);
};
} while(1);
}
unsigned short read_ds1307(unsigned char address)
{
unsigned char Data;
I2C1_Start();
I2C1_Wr(0xd0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C1_Wr(address);
I2C1_Repeated_Start();
I2C1_Wr(0xd1); //0x68 followed by 1 --> 0xD1
Data=I2C1_Rd(0);
I2C1_Stop();
return(Data);
}
void write_ds1307(unsigned char Addr, unsigned char Data)
{
I2C1_Start(); // Issue I2C start signal
I2C1_Wr(0xd0); // Send hardware address for writting
I2C1_Wr(Addr); // Send low byte of the data address
I2C1_Wr(Data); // Send the data
I2C1_Stop(); // Free the bus
return;
}
void StoreToRTC(unsigned char t_or_d)
{
if (t_or_d == 1)
{
bSec = (((bSec / 10) << 4) & 0xF0) + ((bSec-(bSec / 10) * 10) & 0b00001111);
write_ds1307( 0x00, bSec);
bMin = (((bMin / 10) << 4) & 0xF0) + ((bMin-(bMin / 10) * 10) & 0b00001111);
write_ds1307( 0x01, bMin);
bStd = (((bStd / 10) << 4) & 0xF0) + ((bStd-(bStd / 10) * 10) & 0b00001111);
write_ds1307( 0x02, bStd);
}
else if (t_or_d == 2)
{
bDay = (((bDay / 10) << 4) & 0x30) + ((bDay-(bDay / 10) * 10) & 0b00001111);
write_ds1307( 0x04, bDay);
bMon = (((bMon / 10) << 4) & 0x10) + ((bMon-(bMon / 10) * 10) & 0b00001111);
write_ds1307( 0x05, bMon);
bYear = (((bYear / 10) << 4) & 0xF0) + ((bYear-(bYear / 10) * 10) & 0b00001111);
write_ds1307( 0x06, bYear);
}
delay_ms( 2000);
return;
}
void display_time(void)
{
bSec=read_ds1307(0x00); // read second
bSec = ((bSec & 0xF0) >> 4)*10 + (bSec & 0b00001111);
uSec = (unsigned int)bSec;
bMin=read_ds1307(0x01); // read minute
bMin = ((bMin & 0xF0) >> 4)*10 + (bMin & 0b00001111);
uMin = (unsigned int)bMin;
bStd=read_ds1307(0x02); // read hour
bStd = ((bStd & 0x30) >> 4)*10 + (bStd & 0b00001111);
uStd = (unsigned int)bStd;
bDay=read_ds1307(0x04); // read date
bDay = ((bDay & 0x30) >> 4)*10 + (bDay & 0b00001111);
uDay = (unsigned int)bDay;
bMon=read_ds1307(0x05); // read month
bMon = ((bMon & 0x10) >> 4)*10 + (bMon & 0b00001111);
uMon = (unsigned int)bMon;
bYear=read_ds1307(0x06); // read year
bYear = ((bYear & 0xF0)>> 4)*10 + (bYear & 0b00001111);
uYear = (unsigned int)bYear;
if ( (uStd != cStd) || (first == 'Y') )
{
cStd = uStd;
populate_output(uStd);
Lcd_out (1, 13, output);
Lcd_out (1, 15, ":");
}
if ( (uMin != cMin) || (first == 'Y') )
{
cMin = uMin;
populate_output(uMin);
Lcd_out (1, 16, output);
Lcd_out (1, 18, ":");
}
if ( (uSec != cSec) || (first == 'Y') )
{
cSec = uSec;
populate_output(uSec);
Lcd_out (1, 19, output);
}
if ( (uDay != cDay) || (first == 'Y') )
{
cDay = uDay;
populate_output(uDay);
Lcd_out (2, 13, output);
Lcd_out (2, 15, "/");
}
if ( (uMon != cMon) || (first == 'Y') )
{
cMon = uMon;
populate_output(uMon);
Lcd_out (2, 16, output);
Lcd_out (2, 18, "/");
}
if ( (uYear != cYear) || (first == 'Y') )
{
cYear = uYear;
populate_output(uYear);
Lcd_out (2, 19, output);
}
first = 'N';
return;
}
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
i am using a public PC with no mikroC installed...shanpuru wrote:I am using PIC16F877A
sorry my typo there is no such pic as 16F887A (i was in a rush to leave) i meant 16F877A.
i had no IRP error reported.
I am running mikroC pro 3.2 and i have installed the patch too? i also have COFF file generation on by default.
although you could free up RAM by storing much of the LCD data in ROM, if my memory serves me right i think the build still had approx 49% RAM free.
if you want to PM me an email address i will post the hex file i built later tonight. let me know what xtal you are using and if you want watchdog on or off and i can build a hex file for that specific needs.
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
here is an example of storing LCD strings in ROM to cut way down on RAM usage.
Code: Select all
// LCD module connections
sbit LCD_RS at RD2_bit;
sbit LCD_EN at RD3_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;
sbit LCD_RS_Direction at TRISD2_bit;
sbit LCD_EN_Direction at TRISD3_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections
const unsigned char msg1[] = "Message One 1234"; // 16 characters stored in ROM
int i = 0; // loop index to read msg1 array
int Col = 1; // loop index for column position
void main()
{
INTCON.GIE =0; // Global interrupts OFF
CCP1CON = 0;
CCP2CON = 0;
ADCON0 = 0; // ADC off
ADCON1 = 0x7; // All I/O Ports set to digital
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
do
{
Lcd_Chr(1,Col,msg1[i]); // write the contents of msg1 array to the LCD
i++;
Col++;
}while(Col < 17); // just 1 way to control the end write position
Delay_ms(500);
Lcd_Out(2,1,"DONE"); // tell the world i am finished!
}
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
I got similar problems. Can anybody shed us some light?shanpuru wrote:Hi,
Please help me with.
unsigned char output[16];
unsigned char x;
unsigned int y;
If I am using x = output[0]; this works fine
y = 0;
x = output[y]; this gives IRP message
Moreover
32 1511 IRP bit must be set manually for indirect access to 'output' variable clock-and-relays.c
Regards
Shankar
http://www.bestcellulitecreams.org/cell ... tions.html
-
- Posts: 2780
- Joined: 25 Dec 2008 15:22
- Location: Scotland
best option then would be to zip up you project and send it along with a request for help to the support team http://www.mikroe.com/en/support/shanpuru wrote: I am running the full version.
My install shows ver as 3.2 even though the patch 3.21 was installed.
Where could be the problem.
the more detail you give them the greater the quality of help will be.