CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC18, 1-wire and free stack, problems, HELP!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
TMS



Joined: 14 Mar 2006
Posts: 3

View user's profile Send private message Visit poster's website

PIC18, 1-wire and free stack, problems, HELP!!
PostPosted: Tue Mar 14, 2006 9:50 am     Reply with quote

Ok, we use a PIC 18F452 and want to measure a temperature with a DS1820 over a 1-wire bus.
The we want to send this value over ethernet with a RTL8019AS.
For this we use a free TCP/IP Stack from microchip.

We are able to get the value correctly and we can also send it via RS232. But if we write the stack into the program, we don't get any Output on the A0 pin, which is connected to the 1-wire data wire.

If anyone can help us out, we would appreciate that.

thnx so far

Team TMS
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 15, 2006 1:38 am     Reply with quote

Quote:

But if we write the stack into the program, we don't get any Output on
the A0 pin, which is connected to the 1-wire data wire.

Look at the MAINDEMO.C file in this folder:
c:\mchpstackenc8722\source

Notice the following routine. The symbols USE_COMPATIBLE_AD and
USE_LCD are not defined, so that code is not invoked. But even
if the LCD is not used, they still set TRISA = 0x23, which sets RA0 as
an input (and also RA1 and RA5). This explains why you don't get
any output on pin A0.
Code:

static void InitializeBoard(void)
{
// Set up analog features of PORTA
#if defined(USE_COMPATIBLE_AD)     
 ADCON1  = 0b11001110;       // RA0 as analog input, Right justified
#else
 ADCON0 = 0b00000001;   // ADON, Channel 0
 ADCON1 = 0b00001101;  // Vdd/Vss is +/-REF, AN0 and AN1 are analog
 ADCON2 = 0b10000110; // Right justify, no ACQ time, Fosc/64
#endif

#if defined(USE_LCD)
    TRISA   = 0x03;

// LCD is enabled using RA5.
    PORTA_RA5 = 0;          // Disable LCD.
#else
    TRISA   = 0x23;
#endif

Etc.

I suggest that you change the last line which sets TRISA to 0x23
to some suitable value for your board.



Also in the same MAINDEMO.C file, you'll see the following routine.
This routine is full of A/D code in which they turn on the A/D converter
and take a reading, etc.
Code:

static void ProcessIO(void)
{
    WORD_VAL ADCResult;

    /*
     * Select AN0 channel, Fosc/64 clock
     * Works for both compatible and regular A/D modules
     */
    ADCON0      = 0b10000001;

Etc.
}

I suggest that you comment out the line that calls the "ProcessIO()"
function. It's in main(), which is also in the MAINDEMO.C module.

If you do those two things it will probably fix your problem with Port A.
I didn't search everything extensively, but I think this will do it.
TMS



Joined: 14 Mar 2006
Posts: 3

View user's profile Send private message Visit poster's website

PostPosted: Sat Mar 18, 2006 11:24 am     Reply with quote

Thnx for your fast help but we do not use the stack for the ENC28J60. We have uploaded our Stack on this url: http://www.tmsystem.at/v1.0.rar

So if it is possible you could have a look at it.
thx
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 18, 2006 11:55 am     Reply with quote

I don't want to do any more work on it. Look for problems in your
driver similar to the ones I found in the Microchip driver.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Mar 18, 2006 12:48 pm     Reply with quote

The default value for ADCON1 is 0 which configures PORTA as analog inputs. You need to set this register to either 0x06 or 0x07 to configure them as digital i/o.
TMS



Joined: 14 Mar 2006
Posts: 3

View user's profile Send private message Visit poster's website

THX FOR YOUR HELP... SOLUTION
PostPosted: Thu Mar 23, 2006 11:47 am     Reply with quote

Ok we solved the problem now.
So if anyone with the same problem got to this forum topic, HERE IS THE SOLUTION:

Right at the top of the hardware.h:

Code:

#use fast_io(A)

same with B,C,D and E

so if you don't want to set the tris-registers all the time, delete the fast_io.

greetings
Team TMS
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group