View previous topic :: View next topic |
Author |
Message |
TMS
Joined: 14 Mar 2006 Posts: 3
|
PIC18, 1-wire and free stack, problems, HELP!! |
Posted: Tue Mar 14, 2006 9:50 am |
|
|
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
|
|
Posted: Wed Mar 15, 2006 1:38 am |
|
|
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
|
|
Posted: Sat Mar 18, 2006 11:24 am |
|
|
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
|
|
Posted: Sat Mar 18, 2006 11:55 am |
|
|
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
|
|
Posted: Sat Mar 18, 2006 12:48 pm |
|
|
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
|
THX FOR YOUR HELP... SOLUTION |
Posted: Thu Mar 23, 2006 11:47 am |
|
|
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:
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 |
|
|
|