PORTC output

Status
Not open for further replies.

graemeian

New Member
I am using a PIC16f630. and Oshonsoft
In my code , if I use Toggle PORTC.1, all works well.
I can see where it does the page setup for PORTC on the watch page
If I use PORTC.1=0. It is gambler's choice as I cannot see where the status bits are changed if needed for PORTC. If I write a simple high/low loop, I may or may not get a square wave on the output pin.
If I try ASM:LATC,1=0, I get a compile error. The PIC text and Dario both suggest that one uses LATx to write to digital ports. (Dario is one of the strong supporting writers on the PIC forum page.)
What is the preferred way to control output states of the pins using Oshonsoft.
Thank you.
 
Last edited:
First check the pins are set to digital ( ANSELC = 0).. Second! That chip hasn't got LATCH registers...

The RMW issue is only with capacitive loads... Switching an LED fast will not give you any real trouble...

Have you a code snippet so we can see what gives??
 
Sorry about the LATCH thing. I have a 16f630 talking to a 16F1455 that is talking to a PC. I was looking at the wring app notes.

I have something like this:
OPTION.0 = 0
OPTION.1 = 1
OPTION.2 = 1
OPTION.3 = 1

TRISC = %00001000 'SETS THE PORT STATUS
TRISA = %11111111
PORTC.5 = 1 'RED LED off
For i = 1 To 10
WaitMs 50
PORTC.5 = 0 'RED LED on
WaitMs 10
ASM: CLRWDT
PORTC.5 = 1 'RED LED off
Next i
'The above works as I expect with red LED flashing
loop:
'some other code including IF THENs that can skip the below code but it is now commented out.
'and now...

for I = 1 to 20
PORTC.0 = 1
waitMs 250
ASM: CLRWDT
PORTC.0=0
waitMs 250
ASM: CLRWDT
NEXT i

'some more code
Sleep
NOP
Goto loop:

In the second loop, I am turning on/off a 10mA transmitter.
I do not see a voltage toggle. When I replace the "PORTC.1=" pair with a toggle ,
I see the toggle on an o-scope.
I will get back to the PIC later today and add BCF and BSF to the status pages to see if it makes a difference.
Thanks.
 
Last edited:
I still can't see where you turn the ADC off!!!

With Oshonsoft you can use the ALLDIGITAL command... Or use ANSELC = 0.. The analogue module is on by default,,, You have to turn it off!
 
Thank you very much Ian. At some time yesterday, I had commented out the alldigital component hidden in the top of the program.
Starting fresh today, the program is going as expected.
Thanks again.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…