PDA

View Full Version : port handle



kumara
- 30th September 2012, 14:06
dear
i want to write something like this
go_sub1:
go_sub2:
go_sub3:

go_sub1:
high porta.0
goto main

go_sub2:
high portb.1
goto main

go_sub3:
high portb.2
goto main

my pboblem is program goto first go_sub0: then high portb.0 then program goto go_sub1: then high portb.1 but low portb.0.
please write me example for this i want to do portb.0 stay on high with second step.
thank you

mackrackit
- 30th September 2012, 14:51
go_sub1:
high porta.0
goto main
But you are using PORTA in your code.
Post your actual code and we will see what can be done.

kumara
- 1st October 2012, 03:34
dear sir
i have some mistake
iwant to handle portA

go_sub1:
go_sub2:
go_sub3:

go_sub1:
high porta.0
goto main

go_sub2:
high porta.1
goto main

go_sub3:
high porta.2
goto main

rmteo
- 1st October 2012, 03:57
When performing bit write operations on PIC16s, this is something you have to watch out for.


Reading the PORTx register reads the status of the pins, whereas writing to it will write to the PORT latch. All write operations are read-modify-write operations. Therefore, a write to a port implies that the port pins are read, this value is modified and then written to the PORT data latch.

mackrackit
- 1st October 2012, 04:20
Many chips have analog funtions on PORTA, did you turn the ADC off?
http://www.picbasic.co.uk/forum/showthread.php?t=561

kumara
- 2nd October 2012, 07:23
use 16f877a
Adc off
can u help me.with example
thank you

Demon
- 3rd October 2012, 00:32
Did you get the main program structure working?

If it still acts funny, it's probably because the GOTO MAIN in the subroutines always goes back to the top of the program. Only SUB1 will get executed.

What about something like this?



GOTO MAIN ' Skip over subroutines

Sub1:
high portB.0
RETURN

Sub2:
high portB.1
RETURN

Sub3:
high portB.2
RETURN

MAIN:
GOSUB Sub1
GOSUB Sub2
GOSUB Sub3
END


I would recommend starting with Port B for your testing. You can use Port A later once you have a simple program working.

Robert
:)