Dave, The beauty of the 18 series is... NO BANKING WORRIES. * | __O Thomas C. Sefranek WA1RHP@ARRL.NET |_-\<,_ Amateur Radio Operator: WA1RHP (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz http://hamradio.cmcorp.com/inventory/Inventory.html http://www.harvardrepeater.org > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of David Duffy > Sent: Sunday, February 16, 2003 8:19 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Stupid newbie PIC question > > > Neil wrote: > >Today is the first day of programming the PIC for me, so forgive > me if I'm > >asking something that's stupid or has been answered a zillion times. I > >have checked over the various bits of documentation and examples I've > >found and according to what's going on, the code isn't setting the > >TRISA/B/C ports as they should! > > > >I'm using MPLAB version 6.10.0.0 with an 18F252, and here's my code > >snippet: > > > > movlw PORTA_IN ; Get port A's input setting > > movwf TRISA ; Set up appropriate tristating > > > >; Now port B > > > > movlw PORTB_IN ; Get port B's input setting > > movwf TRISB ; Set up appropriate tristating > > > >; Now port C > > > > movlw PORTC_IN ; Get port C's input setting > > movwf TRISC ; Set up appropriate tristating > > > >PORTA_IN = 0x40 > >PORTB_IN = 0x01 > >PORTC_IN = 0xb8 > > > >I have verified that W is getting loaded with the values above (through > >the IDE/debugger). When I read the tristate registers for each > port, I get > >this: > > > >TRISA = 0x00 > >TRISB = 0x81 > >TRISC = 0xB8 > > > >The TRISA/B/C ports *ARE* changing, but TRISA/TRISB aren't coming up with > >the right values. Any idea what I'm doing wrong? Thanks in advance! > > I've not looked at the 18Fxx but the TRIS registers are in bank 1 normally > so you'll have to do something like this: > > bsf rp0 ;select register bank 1 > movlw 0x81 ;get the setting > movwf trisc ;copy it to the tris register > bcf rp0 ;back to register bank 0 > > The ports themselves (in bank 0) are the same address as the tris > registers, only up in register bank 1. It's an easy mistake to make. > David... > ___________________________________________ > David Duffy Audio Visual Devices P/L > U8, 9-11 Trade St, Cleveland 4163 Australia > Ph: +61 7 38210362 Fax: +61 7 38210281 > New Web: www.audiovisualdevices.com.au > ___________________________________________ > > -- > http://www.piclist.com hint: PICList Posts must start with ONE topic: > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics