On Thu, Oct 18, 2001 at 11:50:11PM +0200, Lasse Madsen wrote: > Hi all > > Im still experimenting with the PCLATH register but i cant seem to get it to > work :o( Tell us what's going on with it. > What im trying to do is take input on portb and put it on porta. (just to > try something) This is not a good design problem for what you are trying to learn. PCLATH has very little to do with the problem you're trying to solve. So let me throw out a real world problem that is directly impacted by it: For your LCD display you would like to be able to write one of several dozen fixed messages, represented as NULL terminated strings. Because the total length of all the messages is more than 256 bytes, the message address is represented by two bytes, strhi and strlo. Write a routine that will transfer successive bytes of a message to PORTB until a NULL is reached. Note that the messages must be stored in the program memory of the PIC and you cannot assume that you can read the program memory directly so that you can run this routine on parts like the 16F628. Now this problem cannot be solved without understanding how PCLATH works. Go take a stab at it. Once you solve it, you'll have a very useful routine and a clearer understanding of how PCLATH works. Just remember the rule of thumb: PCLATH is transferred to PCH whenever PCL is directly written. Hope this helps, P.S. On your original code, you could have problems with successive bit sets or clears on an I/O port. Because of the way that ports are set up, a write immediately followed by a read may not transfer all of the bits correctly. Conventional wisdom is to put at least one instruction, possible even a NOP, between successive bit operations on the same port. BAJ -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu