PDA

View Full Version : PIC18F458 Shiftin / Out



pberhin
- 28th May 2006, 19:21
Something wrong with the Shiftin Shiftout

I have the following problem with the shiftin / out function.
Pic used is a 18F458

I used the port D to control an ADC Converter LTC1298 (D4-D7)
and 2 relays (D3 D4) and leds (D0 D1)

LEDNIGHT_Status VAR PortDStatus.0
LEDDAY_Status vAR PortDStatus.1
RELAYNIGHT_Status VAR PortDStatus.2
RELAYDAY_Status VAR PortDStatus.3
CS_Status VAR PortDStatus.4
SCLK_Status VAR PortDStatus.5
DIN_Status VAR PortDStatus.6
DOUT_Status VAR PortDStatus.7
All defined as out except PortD.6

To read the ADC value, I used the following command

CS_Status = 0
PORTD = PortDStatus 'Activate the ADC.
shiftout PORTD.7,PORTD.5,lsbfirst,[config\4] 'Send config bits.
shiftin PORTD.6,PORTD.5,msbpost,[Temp_VOLT\12] 'Get data bits.
CS_Status = 1
PORTD = PortDStatus 'Deactivate the ADC.


This works fine but if one of the ouptut D0-3 is set to 1 before the statement, the output will follow the CS_Status during the shifout or shiftin
statement.

Any idea ?

BigWumpus
- 28th May 2006, 19:26
In your programm, we see no definition of "PortAStatus" !

Why do you put this undeclared value to PortD ?

pberhin
- 29th May 2006, 18:07
I don't use the Port A, so ..

I just tried with another PIC just to see if I didn't had one hardware problem : just the same
I then tried with a 18F452 instead of a 18F458.
With this one , everything just works fine ....

mister_e
- 29th May 2006, 19:12
you need to disable analog comparator on PORTD<3:0> to avoid odd results first.
CMCON=7

about now?

pberhin
- 29th May 2006, 20:36
You're right. I forgot this.
I tried again with the 458. It's works fine
Thanks