![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi all, I am trying to use a glcd (ks1080) connected to a 16F887 (the board that is shipped with the pickit2). After spending hours to find out why the code that is suppose to work doesn't work, I looked at the PORTB's behaviour : if I do (TRISB = 0) bsf PORTB,5 ; this works, the pin5 = 1 bsf PORTB,6 ; pin6 = 1 BUT pin5 comes back to 0 !!!! Anybody got any idea ? Here is how it is connected to the glcd : PORTD = D0..7 PORTB.1 = E PORTB.2 = RW PORTB.4 = RS PORTB.5 = CS1 PORTE.0 = CS2 PORTE.1 = RST Any idea ?? Thx and merry Xmas | |
| |
| | (permalink) |
| This is the famous RMW (read modify write) "feature" of the 16 series pics. You can read an explanation of the problem in the data sheet. The crux of it is that if you set a pin using bsf, the port is read, the bit is set and the port is written back to. If another pin is in transition from a previous write (or the pin is heavily loaded) it gets read as zero. A simple solution is to write to a shadow register (ram) and transfer the ram copy to the port. Mike. | |
| |
| | (permalink) |
| Thx Mike ! | |
| |
| | (permalink) |
| Having thought a little longer, I think you may have a different problem. The CS lines should not load the pin enough to cause the problem you describe. Are you sure the pin (B5) is not shorted to ground or set to analogue (pins set as analogue read back as zero). I have a current project that has a GLCD and an 886 that has similar connections and I haven't had any problems. Mike. | |
| |
| | (permalink) |
| Thanks Mike That explains the problem I had with a bar graph. This would not set PORTB,5 FiveLEDs bsf PORTB,5 bsf PORTB,3 bsf PORTB,2 bsf PORTB,1 bsf PORTB,0 goto LEDsSet But this did FiveLEDs bsf PORTB,3 bsf PORTB,2 bsf PORTB,1 bsf PORTB,0 bsf PORTB,5 ;Had to set bit 5 last WTF ??? goto LEDsSet
__________________ C:\WHUT ? Beware the asterisk * | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Problem with LCD code? | spondootre | Micro Controllers | 15 | 29th April 2008 10:15 AM |
| DS1302 with PIC16f877 program | RasCreationKing | Micro Controllers | 28 | 3rd May 2007 01:03 PM |
| Validating Code Without PIC | burg | Micro Controllers | 4 | 22nd April 2007 05:14 PM |
| Very strange problem with portb in 16F628 | patroclus | Micro Controllers | 3 | 2nd December 2005 02:20 PM |
| MPLAB strange behaviour? | RGBrainbow | Micro Controllers | 0 | 22nd June 2005 08:21 PM |