Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error in Building the code... Help me Please....

Status
Not open for further replies.

Ram Prasadh

Member level 2
Joined
Feb 16, 2011
Messages
51
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,725
Hi

I am presently on a project regarding spi in pic16f72. I get a problem when I build this codeIt states like

"Error [1091] C:\Program Files\HI-TECH Software\PICC\9.71a\sources\float.c; 86. main function "_main" not defined".

My code is below and I have also given the output window. Please help me with this Problem.



#include<htc.h>
void spi();
void delay();
typedef unsigned int word;
word __at 0x2007 CONFIG = _HS_OSC & _WDT_OFF & _PWRTE_OFF & _CP_OFF & _BODEN_ON;
#define SS PORTAbits.RA5//slave select bit is assigned to porta 5th pin


void main(void)
{
ADCON1=0x06;//configured as digital and not analog
TRISA=0;
TRISC=0;
TRISCbits.TRISC4=1;// SDI is made as an input,SCK,SDO are output
spi();
}
while(1)
{

void spi()
{

/*_ _ _ _ _ _ _ _ _ SSP CONFIGIRATION_ _ _ _ _ _ _ _ _ */

SSPCON=0b00110001;
SSPSTAT=0b10000000;
SS=0x00;
WREG=0x23;
SSPBUF=WREG;
while(BF=0x00);
PORTB=SSPBUF;
SS=1;
}
}









my output comes like this:


Build C:\Documents and Settings\RAM PRASADH\My Documents\pic\spi for device 16F72
Using driver C:\Program Files\HI-TECH Software\PICC\9.71a\bin\picc.exe

Make: The target "C:\Documents and Settings\RAM PRASADH\My Documents\pic\SPI2.p1" is up to date.
Executing: "C:\Program Files\HI-TECH Software\PICC\9.71a\bin\picc.exe" -ospi.cof -mspi.map --summary=default,-psect,-class,+mem,-hex --output=default,+inhx032 SPI2.p1 --chip=16F72 -P --runtime=default,+clear,+init,-keep,+osccal,+download,-resetbits,-stackcall,+clib --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Licensed for evaluation purposes only.
This licence will expire on Thu, 12 May 2011.
HI-TECH C Compiler for PIC10/12/16 MCUs (PRO Mode) V9.71a
Copyright (C) 2010 Microchip Technology Inc.
Error [1091] C:\Program Files\HI-TECH Software\PICC\9.71a\sources\float.c; 86. main function "_main" not defined

********** Build failed! **********


Help me Please......
 

copy these 3 lines
void spi();
void delay();
typedef unsigned int word;


just before the main () ............. not after # include

---------- Post added at 18:05 ---------- Previous post was at 18:03 ----------

why you have out spi() in a while loop??? even after removing errors i doubt if it would work?????????

---------- Post added at 18:05 ---------- Previous post was at 18:05 ----------

why you have out spi() in a while loop??? even after removing errors i doubt if it would work?????????
 

in SPI the while loop is to wait to complete the transmission (initialized with SSPBUF=WREG). Normally it should work despite that there is no timeout. But I agree with you - such code will tend to create deadlocks if something is not OK (for example in this case if the SPI was not switched ON).

In my opinion the brace before while() is incorrectly set. First fix this and then continue - see attached PDF
 

Attachments

  • temp.pdf
    22.5 KB · Views: 109
Last edited:
please correct your parenthesis....
what is while(1) doing in between main and spi function...
always use indentation in your code it makes it easier to understand specially help in dealing with the parenthesis.....
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top