PICcoder.co.uk Forum  


::post new topic::
<< Start < Prev 1 2 Next > End >>
beginner with C18 compiler
Date: 2006/03/29 19:24 By: Queen Status: Visitor  
 
Hi
Am beginnig with C18 compiler to program a pic18 and using tcp/ip stack, but each time include files I get several errors, please give me some information to do my project?
I will illustrate what am I do:
I want to transfer a value that recieved from A0 by using ethernet cable to the computer, I think only need to use TCP, IP protocols, here is the code:
Code:

 #include "p18f252.h" #include "TCP.h"  void msDelay(unsigned int);  unsigned char ADC(void); void main(){ int results; //initialization PORTA=0x00//clear port A TRISA=0xFF//set PORTD to input ADCON1=0b00101110;//left justified, Fosc/16, AN0 analog //rest digital, Vref+=VDD and Vref-=VSS ADCON0=0B10000001//Fosc/16, Channel 0, ADC power on //endless loop again: results=ADC(); //get conversion PORTB=0x00; TRISB=0x00; PORTB=results; if (PORTB=0B10000000){ TCPInit(); } msDelay(10); goto again//one more time } #define IMAX 10 void msDelay(unsigned int count){ unsigned int outer//loop counters unsigned char inner; for(outer=0;outer <countouter++){ for(inner=0;inner<IMAX;inner++) Nop(); } } unsigned char ADC(void){ ADCON0bits.GO_DONE=1//start conversion while(ADCON0bits.GO_DONE); //wait for end of conversion return ADRESH; }




the last error I was get is:
Executing: "C:MCC18binmplink.exe" /l"C:MCC18lib" /k"C:MCC18lkr" "C:MCC18lkr18f252.lkr" "C:123456789sensor.o" "C:MCC18hTCP.o" "C:MCC18hTick.o" "C:MCC18hHelpers.o" "C:MCC18hIP.o" "C:MCC18hMAC.o" "C:MCC18hStackTsk.o" /m"C:123456~1123456789.map" /w /o"123456789.cof"
MPLINK 4.02, Linker
Copyright (c) 2006 Microchip Technology Inc.
Error - could not find definition of symbol 'AppConfig' in file 'C:MCC18hTCP.o'.
Errors : 1

BUILD FAILED: Wed Mar 29 20:53:10 2006
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/29 22:05 By: Ian Status: User  
Karma: 5  
Posts: 85
graphgraph
The TCP layer requires other code such as the mac layer.

You need a couple more includes.

Something like

/*
* These headers must be included for required defs.
*/
#include "StackTsk.h"
#include "Tick.h"
#include "MAC.h"
#include "Helpers.h"

Then you need to initate the stack and the mac layer.

Search the source for the definition of AppConfig.

You might find it easier start from the maindemo.c and cut it down rather than start from scratch.

Ian
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/30 15:16 By: Queen Status: Visitor  
 
Am trying to start from maindemo.c but still having errors.
Am starting with the mpnicpg.mcp and only change the file whose name is maindemo.c into sensor.c >> the code changes but I still have errors.
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/30 16:39 By: Ian Status: User  
Karma: 5  
Posts: 85
graphgraph
Can you compile the basic project? Without your changes?

Ian
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/30 17:04 By: Queen Status: Visitor  
 
Yes, I compile it without any problem but when I exchange the maindemo.c with sensor.c(the prevoius code I attached it) I have an errors
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/30 18:54 By: Ian Status: User  
Karma: 5  
Posts: 85
graphgraph
Your sensors.c initalises the tcp layer of the TCP stack. TCP relies on MAC and other sections of the stack. You need to include and initalise at least the MAC and stacktask.

The stacktask needs to be run regular to process the tcp and mac layer protocol.

I didn't mean to replace the maindemo.c completely. I ment start with maindemo.c and cut bits out while adding in your sections of code.

Also TCPInit only initalises the TCP stack, it doesn't send any data. It doesn't need to be called in your loop and should only be called once.

Ian
reply | quote

Re:beginner with C18 compiler
Date: 2006/03/30 23:32 By: Queen Status: Visitor  
 
Hi
when I am trying to compile our project, I encounter the following errors:
Error - symbol 'NICCurrentTxBuffer' has multiple definitions.
Please, anyone can check the file and find how to repair this error, the most importnat thing is making compilation for the project, the function of the code is not important to be correct.
The project can be downloaded from the following:
http://rapidshare.de/files/16830710/Project.zip.html
reply | quote

Re:beginner with C18 compiler
Date: 2006/04/04 15:08 By: Queen Status: Visitor  
 
Hi can anyone help me in the following syntax error:
typedef union _IP_ADDR //IP address
{
BYTE v[4];
DWORD Val;
} IP_ADDR;
IP_ADDR RemoteIPAddr;

when am write the following line, I have a syntax error
RemoteIPAddr.v[0] = '1';
RemoteIPAddr.v[1] = '';
RemoteIPAddr.v[2] = '168';
RemoteIPAddr.v[3] = '192';

why plz???
reply | quote

Re:beginner with C18 compiler
Date: 2006/04/08 14:46 By: lycaste Status: User  
Karma: 0  
Posts: 1
graphgraph
delete the quotes please, v is a byte binary number.
reply | quote

Re:beginner with C18 compiler
Date: 2006/04/08 15:25 By: Ian Status: User  
Karma: 5  
Posts: 85
graphgraph
Are you using the enc28j60? I'll assume you are.

Remove mac.c from your project.

You only need one set of mac definitions and the enc28j60.c file contains all the mac layer for the enc28j60. (you will still need the mac.h file)

Hope that helps.
reply | quote

Re:beginner with C18 compiler
Date: 2006/04/18 19:33 By: Queen Status: Visitor  
 
Hi again,
I make some modifications on the code, can anyone give me his/her opinioin, please.
OR, Can anyone test the code on his board if it will work or not

http://rapidshare.de/files/17494398/project.zip.html
reply | quote

<< Start < Prev 1 2 Next > End >>
::post new topic::