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 ?
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 ?