Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic porta and porte problem

Status
Not open for further replies.

seyyah

Advanced Member level 2
Joined
Oct 7, 2001
Messages
646
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,298
Activity points
6,233
pic bsf porta bug

BSF STATUS,RP0 ;BANK1

MOVLW B'00000110'
MOVWF ADCON1

CLRF TRISE

BCF STATUS,RP0 ;BANK0


BSF PORTE,0
BSF PORTE,1
BSF PORTE,2


When i use porta and porte as digital i/o, i can't use bsf and bcf with these ports like other ports. In the above code. Only porte[2] remains 1 and others are 0. For which bit i use bsf, that bit is set to 1 and others are set to 0. I couldn't resolved this. This porblem is only with porta and porte. I tried portb; it's ok. Am i doing something wrong?
 

ALL DIGITAL OUTPUTS PORTS A & E

BCF STATUS,RP1 ;CLEAR BANK 2/3
BSF STATUS,RP0 ;SET BANK 1 BITS
MOVLW b'00000111' ;PORTS ALL DIGITAL FUNCTIONS PORTS PINS
MOVWF ADCON1 ; LOAD IT TO ADCON1
CLRF TRISA ; ALL PORTA FOR ALL OUTPUTS
CLRF TRISE ; ALL PORTE SET ALL OUTPUTS
BCF STATUS,RP0 ; RESET TO BANK 0
CLRW ;TIDY UP


DIGITAL ALL OUTPUTS EXCEPT E0 OPTIONAL I/O PIN ON E

BCF STATUS,RP1 ;CLEAR BANK 2/3
BSF STATUS,RP0 ;SET BANK 1 BITS
MOVLW b'00000111' ;PORTS ALL DIGITAL FUNCTIONS PORTS PINS
MOVWF ADCON1 ; LOAD IT TO ADCON1
CLRF TRISA ; ALL PORTA FOR ALL OUTPUTS
CLRW ; CLEAR W REGISTER
MOVLW b'11111110' ; INSTEAD OF CLRF TRISE YOU CAN
MOVWF TRISE ;HERE TO SET A PIN FOR EXAMPLE AS AN I/O
// CLRF TRISE ; ALL PORTE SET ALL OUTPUTS
BCF STATUS,RP0 ; RESET TO BANK 0
CLRW ;TIDY UP
OR

FOR ALL DIGITAL INPUTS PORT A AND E

BCF STATUS,RP1 ;CLEAR BANK 2/3
BSF STATUS,RP0 ;SET BANK 1 BITS
MOVLW b'00000111' ;PORTS ALL DIGITAL FUNCTIONS PORTS PINS
MOVWF ADCON1 ; LOAD IT TO ADCON1 REGISTER
MOVLW b'00111111' ; SET ALL PINS BOTH PORT FOR INPUT
MOVWF TRISA ; ALL PORTA FOR ALL OUTPUTS
MOVWF TRISE ; ALL PORTE SET ALL OUTPUTS
BCF STATUS,RP0 ; RESET TO BANK 0
CLRW ;TIDY UP

TRIS E WILL IGNORE THE BITS 3 TO 7 THIS WAY

http://www.epemag.wimborne.co.uk/pictutorial.pdf
FIRST FEW PAGES ARE THE BEST
REST IS HIS OWN COMPILER YOU MAY NEED TO THINK CAREFULLY IF YOU WANT TO BIT SET PORT E WHILE USING PORT A AS ANALOGUE BUT IT IS ALL EASILY POSSIBLE

DEFINATLY READ THIS GOOD TEXTS NOW
**broken link removed**
:D
 

OK, i have done the same thing which you are saying.
BSF porte,0 makes porte[0]=1 after this when this code comes
bsf porte,1 port[1] must be 1 and porte[0] musn't change and stay 1.
But it changes to zero.
I think this is a error. This becomes in isis both in old versions and new versions. Mplab 6.30 gives different result and works as expected.
I will try it with real pic also.
 

In real it works without problem. But in isis it doesn't. Is this a bug or is there something else?
 

Seems you are using PIC with ADC. By default ADC is turned on and all analog pins are inputs. Clear ADON bit in ADCON0 register.
 

It didn't change anything. The same code works in real, it doesn't work in isis correctly.
 

ahhaaaa
it appears many many bugs in isis model for pic 877

here is an example code
that inits every port as an output or as an i/o choose by

but only inits and sets to zero

even with the break point set
doing this you would expect the simulator to stop in the initalised state

but the simulator must have to exec the dll routine and init is part of it
so when the simulator stops after the init
it wont have completed the register set up fully

so it is a fault in the apps symantics or in its routines placments


if you use this hex code in pic simulator ide it sets all the ports but leaves all at zero in the non sim state {a nice touch } this way you can quickly get an init correct as it is all infront of you

so perhaps using both is the way to work
rollon a service pak 8)
 

further

a test with pic simulator ide
confirms that all ports report as outputs with above hex files

so it is narrowed down to the model

perhaps the older model dosnt have these limits
look for the pic87x.dll from an older version however you noted that it didnt work also {pre sp6 v5.2} {i found it not to work with any version of the lite with a key so its not any patch or other..


other than this my advice is to try pic simulator ide
its heeps better by far on accuricy with no limits
or any problems after trying the full program with keys
it works fine and i bought it

so... its a cheep reliable tool that has just proved its self worth having
 

hello

after writing a bit set routine {i have a sore arm now}
it appears all port pins work but only after 1 cycle of the code

have a look at this port blaster bit set routine to strobe a snake round the processors ports

it is slowed to 500 hz clock to see the steppings

youll notice also funny thing is port A4 dosnt work
but the rest do !!!!! in pic87xdll anyway....


what a blunder from labcenter.....
wrong simulator symantics and no Ra4 bit set features

perhaps someone can draw up some more cyclic tests for other ranges
have a look

you simply need maybe to re-position the breakpoint properly
to allow for init cycles

i confirmed this operations in pic simulator ide
and again in this app it worked as expected and bits sets every single bit


i added further tests {all work ok remember in pic simulator ide}
for the rest of the 16F87X series in isis
all report pin RA4 out of range {not itterating it}
so this could be the itfmodel to check
i added a logic analyzer and checked the port
it looks like there is an output but it is 1 10th of the cycle
pulse width so dosnt trigger the itfmodel properly

looking further into it i realised that the start breakpoint when you press pause to start the sim
will complete one cycle
this explains why the e0 port pin overflows it will be something to do with the first pass before a pause and where the breakpoint is
i will try moving it into just after the init
to see what happens although
i didnt alos set an org memory vecter
but i dont think this is too important
 

Hmm. When i added pull-up resistors to the ports, it began to work properly.
 

hum

they arent nessisary and infact this is the wrong event data

as it boots and loads the init
i have confirmed this is the case
on a real micro 877 type also and as expected it runs fine
just an init gives cleared registers all low as expected

also on picsimulator ide and it performs as per the chip

so.. if this cured the problem for you

well done

but did you mean port E0 ? and port pin A4 ??

cured by this method ?? or perhaps both ??
so the model is missing port pullups on these pins i think it is more like a few pin direction statements are missing or wrongly placed in the sources
 

I wrote the source in my first message. ra4 isn't used. PortE is used completely here. If there was an error, it wasn't work in real. In my real work i use some of the porta bits and all of the porte bits as digital output. To test, i drove 3 leds from porte pins. All leds have series resistors. In this arrangement it din't work properly. When i add pullup resistors in series with leds it worked perfect.
 

IF USE PORTA Y PORTE WHO PORT DIGITAL CONFIG:
TRISA = INPUT o OUTPUT;
TRISE = INPUT o OUTPUT:
ADCON0 = 0b00000110;


IF USE PORTA Y PORTE WHO PORT ANALOG CONFIG:
TRISA = INPUT;
TRISE = INPUT:
ADCON0 = 0b10000000;
 

Ok we know it. And if you look at previous messages we did like that. The problem isn't that. By the way we don't use adcon0, we use adcon1.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top