ERROR "main function not defined"

General discussion on mikroC.
Post Reply
Author
Message
vishaletm
Posts: 50
Joined: 26 Jan 2012 05:09
Contact:

ERROR "main function not defined"

#1 Post by vishaletm » 26 Jan 2012 05:17

This is my code. I copied it from help of MANCHESTER library. And getting these error "main function not defined"
Please help me...



// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

// Manchester module connections
sbit MANRXPIN at RC0_bit;
sbit MANRXPIN_Direction at TRISC0_bit;
sbit MANTXPIN at RC1_bit;
sbit MANTXPIN_Direction at TRISC1_bit;
// End Manchester module connections

char error, ErrorCount, temp;

void main() {
ErrorCount = 0;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
TRISC.F5 = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display

Man_Receive_Init(); // Initialize Receiver

while (1) { // Endless loop

Lcd_Cmd(_LCD_FIRST_ROW); // Move cursor to the 1st row

while (1) { // Wait for the "start" byte
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
break; // We got the starting sequence
if (error) // Exit so we do not loop forever
break;
}

do
{
temp = Man_Receive(&error); // Attempt byte receive
if (error) { // If error occured
Lcd_Chr_CP('?'); // Write question mark on LCD
ErrorCount++; // Update error counter
if (ErrorCount > 20) { // In case of multiple errors
temp = Man_Synchro(); // Try to synchronize again
//Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount = 0; // Reset error counter
}
}
else { // No error occured
if (temp != 0x0E) // If "End" byte was received
// (see Transmitter example)
Lcd_Chr_CP(temp); // do not write received byte on LCD
}
Delay_ms(25);
}while (temp != 0x0E); // If "End" byte was received exit do loop
}
}
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.

vishaletm
Posts: 50
Joined: 26 Jan 2012 05:09
Contact:

Re: ERROR "main function not defined"

#2 Post by vishaletm » 26 Jan 2012 08:26

When i copy the main function to MikroC avr it works fine this is the code


// LCD module connections
sbit LCD_RS at PORTD2_bit;
sbit LCD_EN at PORTD3_bit;
sbit LCD_D4 at PORTD4_bit;
sbit LCD_D5 at PORTD5_bit;
sbit LCD_D6 at PORTD6_bit;
sbit LCD_D7 at PORTD7_bit;

sbit LCD_RS_Direction at DDD2_bit;
sbit LCD_EN_Direction at DDD3_bit;
sbit LCD_D4_Direction at DDD4_bit;
sbit LCD_D5_Direction at DDD5_bit;
sbit LCD_D6_Direction at DDD6_bit;
sbit LCD_D7_Direction at DDD7_bit;
// End LCD module connections

// Manchester module connections
sbit MANRXPIN at PINB0_bit;
sbit MANRXPIN_Direction at DDB0_bit;
sbit MANTXPIN at PORTB1_bit;
sbit MANTXPIN_Direction at DDB1_bit;
// End Manchester module connections

char error, ErrorCount, temp;

void main() {
ErrorCount = 0;
//ANSEL = 0; // Configure AN pins as digital I/O
//ANSELH = 0;
//C1ON_bit = 0; // Disable comparators
//C2ON_bit = 0;
//TRISC.F5 = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display

Man_Receive_Init(); // Initialize Receiver

while (1) { // Endless loop

Lcd_Cmd(_LCD_FIRST_ROW); // Move cursor to the 1st row

while (1) { // Wait for the "start" byte
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
break; // We got the starting sequence
if (error) // Exit so we do not loop forever
break;
}

do
{
temp = Man_Receive(&error); // Attempt byte receive
if (error) { // If error occured
Lcd_Chr_CP('?'); // Write question mark on LCD
ErrorCount++; // Update error counter
if (ErrorCount > 20) { // In case of multiple errors
temp = Man_Synchro(); // Try to synchronize again
//Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount = 0; // Reset error counter
}
}
else { // No error occured
if (temp != 0x0E) // If "End" byte was received(see Transmitter example)
Lcd_Chr_CP(temp); // do not write received byte on LCD
}
Delay_ms(25);
}
while (temp != 0x0E) ; // If "End" byte was received exit do loop
}
}
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: ERROR "main function not defined"

#3 Post by filip » 26 Jan 2012 09:52

Hi,

I believe I have answered you here :
http://www.mikroe.com/forum/viewtopic.php?f=13&t=15952

Regards,
Filip.

vishaletm
Posts: 50
Joined: 26 Jan 2012 05:09
Contact:

Re: ERROR "main function not defined"

#4 Post by vishaletm » 27 Jan 2012 05:24

I have seen the post...
Actually i didn't include the source file where i pasted the code. I dont know how to include the source to project manager. Normally its not necessary to include it, what is the difference?
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.

vishaletm
Posts: 50
Joined: 26 Jan 2012 05:09
Contact:

Re: ERROR "main function not defined"

#5 Post by vishaletm » 27 Jan 2012 05:58

Thank you... I compiled and simulated successfully.



I need some help fo DS1307 RTC...is there any library for that?
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: ERROR "main function not defined"

#6 Post by filip » 27 Jan 2012 09:17

Hi,

We have the sample code for DS1307, which can be found here :
http://www.mikroe.com/eng/products/view/197/rtc2-board/

Regards,
Filip.

vishaletm
Posts: 50
Joined: 26 Jan 2012 05:09
Contact:

Re: ERROR "main function not defined"

#7 Post by vishaletm » 27 Jan 2012 10:10

But the sample code cannot reset or change the time? How can i change the time?
And schematics. If thre is no library is ther any way to get the commands for DS1307?



Thank You for your help
http://microcontrollerprojects00.blogspot.com/
ARM, PIC , AVR, 8051 Projects/Tutorials (MikroC)
If you get, give. If you learn, teach.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: ERROR "main function not defined"

#8 Post by filip » 30 Jan 2012 13:03

Hi,

For the commands list, please refer to the DS1307 datasheet :
http://datasheets.maxim-ic.com/en/ds/DS1307.pdf

Regards,
Filip.

Post Reply

Return to “mikroC General”