jan-erik, The code could be written the way you show, but it doesn't have to be.=20 I agree that normally you should use symbols for addresses, but in this case, I chose addresses because I was troubleshooting a problem. And to those who suggested I should change the the ASNELB from clearing bit 7 to clearing the whole register are indeed correct. When I was=20 doing the setup, I cut and pasted the same routine and changed the page and label. But on that one, I didn't change enough. I knew the problem was something simple. I just didn't see it. That's why more than one set of eyes are a good thing in=20 situations like this. Anyway, it works as intended now. Thanks all, Regards, Jim > -------- Original Message -------- > Subject: Re: [FWD: [PIC]: PIC16F1827 PORTB Problem.] *** RESEND *** > From: Jan-Erik Soderholm > Date: Tue, June 21, 2011 12:51 am > To: "Microcontroller discussion list - Public." >=20 >=20 > If i'm not wrong, that code should/could be written like > this on the enhanced PIC16 models : >=20 > clrf PORTB ; Clear the PORT >=20 > movlb TRISB > clrf TRISB > movlb RCSTA > bsf RCSTA,7 > movlb ANSELB > bcf ANSELB,7 ; Should probably be a clrf... > movlb SSP1CON1 > clrf SSP1CON1 > clrf SSP2CON1 > movlb ADCON0 > clrf ADCON0 > movlb CPSCON0 > clrf CPSCON0 > movlb MDCON > clrf MDCON > movlb DACCON0 > clrf DACCON0 > movlb CM1CON0 > clrf CM1CON0 >=20 > And *never* write out the actual address to registers > (such as 0x08), always use symbols (BSR in this case). >=20 >=20 > Oli Glaser wrote 2011-06-21 02:13: > > On 20/06/2011 23:18, jim@jpes.com wrote: > >> Let me try this again without all the typos and spelling mistakes. > >> That's what I get for going too fast. > >> > >> All, > >> > >> I am trying to get familiar with the PIC16F1827 part that has the > >> Capacitive Sensing Module on it. > >> As a start, I am setting each bit on PORTB sequentially. This is = just > >> a familiarization exercise. > >> However, I can't get bits 1,2 and 5 to toggle. I have tried turni= ng > >> off any module associated with > >> PORTB, but I still cannot get it to work. Bits 0, 3, 4, 6, and 7 w= ork > >> fine. > >> I am probably missing turning off something, but I just don't see = what > >> it is. > >> > >> Below is listed what I have tried turning off so far. > >> > >> clrf PORTB ; Clear the PORT > >> > >> movlw 0x01 ; Make pins OUTPUTS > >> movwf 0x08 > >> clrf TRISB > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x03 ; Disable Serial Port (UART) > >> movwf 0x08 > >> bsf RCSTA,7 > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x03 ; Make Pins Digital, Not Analog > >> movwf 0x08 > >> bcf ANSELB,7 > >> movlw 0x00 > >> movwf 0x08 > >> =09 > >> movlw 0x04 ; Turn Off Synchronous Serial Ports (SPI& I2C) > >> movwf 0x08 > >> clrf SSP1CON1 > >> clrf SSP2CON1 > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x01 ; Turn Off A/D Converter > >> movwf 0x08 > >> clrf ADCON0 > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x00 ; Turn Off Capacitive Sense Module > >> movwf 0x08 > >> clrf CPSCON0 > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x07 ; Turn Off Digital Signal Modulator > >> movwf 0x08 > >> clrf MDCON > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x02 ; Turn Off D/A Converter Module > >> movwf 0x08 > >> clrf DACCON0 > >> movlw 0x00 > >> movwf 0x08 > >> > >> movlw 0x02 ; Turn Off Comparator Module > >> movwf 0x08 > >> clrf CM1CON0 > >> movlw 0x00 > >> movwf 0x08 > >> > >> If anyone sees anything that I am doing wrong, or sees something t= hat > >> I am missing turning off > >> (or on if it should be on) to make PORTB work, please let me know.= I > >> appreciate it. > >> > >> Thanks and Regards, > >> > >> Jim > >> > >> > >> > >> > > > > Shouldn't that be clrf ANSELB if you want make all the pins digital? > > Although it shouldn't affect the output.. > > Couple of guesses: > > Just checked my datasheet and it says it has more than one I2C/SPI > > peripheral - check page 126, section 12.3.4 for the pin priorities and > > see if you can see anything there. I would turn SSPCON2 off to start > > with, and the CCP peripheral. > > Check you are not having a rmw issue when you toggle the pins too. > > > > > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .