port - Configure a PIC pin for Input and Output -


i working on project uses pic24fj64ga002 mcu. working on bit-banged serial communication function use 1 wire send data , switch receive mode receive data on same pin. separate pin used clocking controlled different board (always input). wondering there way configure pin open-collector operation that can used input , and output or have change pin configuration every time go reading writing?

you need change direction of pin each time using tris register. if pin set output, reading port register tell level driving pin (assuming there high impedance on pin). if pin set input, won't able drive desired output value. also, make sure read incoming data using port register, output data using lat register. ensures don't suffer issues if code (i assume programming in c here) gets converted bset/bclr/btgl instructions read-modify-write. if writing in assembler, same rule applies know when using these r-m-w type instructions. if want more reasoning on this, please ask.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -