This is almost certainly a peripheral-related issue, especially if the 'pause 100' makes a difference. Something is writing to the port or turning outputs to inputs during the RMW operation.
As Henrik asked, which PIC?
This is almost certainly a peripheral-related issue, especially if the 'pause 100' makes a difference. Something is writing to the port or turning outputs to inputs during the RMW operation.
As Henrik asked, which PIC?
I am using a PIC16F873A, I am connecting the output pins directly to an ATMEL microcontroller, the ATMEL microcontroller have pullup resistors in the corresponding inputs, but the initial state of all my output pins is set to High in the begginning of the program for the ATMEL microcontroller be compatible with negative logic.
I am using the USART of the PIC using an Assembler routine for the interrupt handler. When I send certain message to the USART via it´s input, the program evaluates the message, then changes the pin outputs, now I am working with PAUSE 10 between each output statement.
I can not assign directly to PORT registers because of the USART connected to some pins of PORTC.
Thanks for all your answers!
So what you are saying is that you didn't try the method I mentioned about the shadow register. It should still work. On most PICs the USART takes over the function of the pins so writing to PORTC.6 and PORTC.7 is then impossible.
Charles Linquist
Yes, I am using your shadow method, but it only works with adding pauses this way:
PORTC.0 = 1
PAUSE 10
PORTC.1 = 1
PAUSE 10
PORTC.2 = 1
PAUSE 10
PORTC.3 = 1
If I remove the pauses, then the thing does not work...
Thank you very much again.
What if you did it like this?
Code:ShadowC VAR byte ShadowC = PORTC ShadowC.0 = 1 PORTC = ShadowC ShadowC.1 = 1 PORTC = ShadowC ShadowC.2 = 1 PORTC = ShadowC ShadowC.3 = 1 PORTC = ShadowC
Why pay for overpriced toys when you can have
professional grade tools for FREE!!!
I want to thank you very much.
The problem is resolved, now I am setting the pin output states super fast!
The final working code was the one posted by rmteo, but thank you all really!
ShadowC VAR byte
ShadowC = PORTC
ShadowC.0 = 1
PORTC = ShadowC
ShadowC.1 = 1
PORTC = ShadowC
ShadowC.2 = 1
PORTC = ShadowC
ShadowC.3 = 1
PORTC = ShadowC
You can do it even faster by doing it the way Charles originally showed you, (did you REALLY try that and it didn't work?) in other words:/Henrik.Code:ShadowC VAR BYTE ShadowC = PortC ShadowC.0=1 ShadowC.1=1 ShadowC.2=1 ShadowC.3=1 PortC = ShadowC
Bookmarks