hi friends,
now I am working with the pic18f1320, but I dont know how to set the portA and portB as the I/O ports, in the assembly language.
also I am not verysure how to configure the pic in assembly,
please share your experience.
thanks
how to set portA/B of pic18f1320
-
- Posts: 61
- Joined: Thu Dec 20, 2007 4:23 pm
- Location: singapore
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: how to set portA/B of pic18f1320
Hello Saran
I wouldn't recommend assembler language unless you must have direct control over every single instruction. However if you have your heart set on it you must do the following.
Find the bit in the status register that controls the bank switching. This is normally named RP0.
Set this bit to move into Bank1.
When in bank 1 you can write a value to the TrisA and TrisB registers which will configure the I/O operation. 1=Input, 0=output.
Then Switch back to bank 0 by clearing the bit in the status register.
Then read or write to registers PortA and PortB to control the I/O functionality.
Microchip C would use the same method but is much easier to code. BoostC is even easier as it does all of the bank switching functionality for you.
Eg in BoostC you would do the following.
Write value to tris register
Read / Write value to port register.
I wouldn't recommend assembler language unless you must have direct control over every single instruction. However if you have your heart set on it you must do the following.
Find the bit in the status register that controls the bank switching. This is normally named RP0.
Set this bit to move into Bank1.
When in bank 1 you can write a value to the TrisA and TrisB registers which will configure the I/O operation. 1=Input, 0=output.
Then Switch back to bank 0 by clearing the bit in the status register.
Then read or write to registers PortA and PortB to control the I/O functionality.
Microchip C would use the same method but is much easier to code. BoostC is even easier as it does all of the bank switching functionality for you.
Eg in BoostC you would do the following.
Write value to tris register
Read / Write value to port register.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel