'Idiots Guide' to portc...

Mikler

Member
Hi!

I am using a 28X1. Forgive me if it is in the manual, but I must be misunderstanding.

I use 'let dirsC=%11111100' to set c6 and c7 as an output

I had assumed that they would behave like the 'standard' outputs.

However, with the following code (I am driving two LEDs)

low portc 6
pause
low portc 7

Unlike with the standard output, as soon as portc 7 goes low, portc 6 goes high...

I want to have them both low at the same time....

Or do I have to use the 'let pinsc =%11111111' command? Aaargh!!!
What am I missing here?

Comments appreciated.

Thanks

Mik
 

westaust55

Moderator
Mik,

Can you upload your exact code for members to look at.
Clearly you are not using the code:
low portc 6
pause ??
low portc 7

because pause needs a value to compile and download otherwise you get a syntax error.

your line:
dirsC=%11111100
to set c6 and c7 as an outputs is okay but in line with what others have mentioned above.
However, if you are only seeking to make pins 6 and 7 high, then use:
dirsC=%11000000 (bits are in the order 7,6,5,4,3,2,1,0)
 
Last edited:

westaust55

Moderator
This code works as expected in the simulator:

Code:
let dirsC=%11000000 ; to set c6 and c7 as an output

main:

low portc 6

pause 2000

low portc 7

pause 2000

high portc 6

pause 2000

high portc 7

pause 2000

goto main
 

Mikler

Member
To Wesyaust55

I ran your code

I illustrates my problem exactly as I am having it.

I have outputs from the two pins going to two leds, the other sides of the leds going to '+'

At no time are both LEDs on at the same time - according you your code, the first one turn on, then the second one comes on (ie both together) - what is happening is that as soon as the second onr switches on, the second one turns off...

Or can one not use code like this (code that is valid for the normal 'outputs'.)???

Mik
 

Mikler

Member
Attn: Tarzan

Does that mean that if I want both outputs on, I have to use:
pinsc = %11000000

and that I can't use the normal 'low portc' and 'high portc' commands?
 

hippy

Ex-Staff (retired)
What version 28X1 Firmware do you have ?
Which Programming Editor version are you using ?

I tested this on 28X1 A.4 and it worked as expected. Regardless of whether LED's go to 0V or to +V the sequencing should appear the same ...

Code:
#picaxe28x1

dirsc = %11000000

Do
                 Low  PortC 6 : Pause 1000 ' -- Both off
                 High PortC 6 : Pause 1000 ' -* 7 off, 6 on
  High PortC 7                : Pause 1000 ' ** Both on
                 Low  PortC 6 : Pause 1000 ' *- 7 on, 6 off
  Low  PortC 7                : Pause 1000 ' -- Both off
  High PortC 7                : Pause 1000 ' *- 7 on, 6 off
                 High PortC 6 : Pause 1000 ' ** Both on
  Low  PortC 7                : Pause 1000 ' -* 7 off, 6 on
Loop
 
Last edited:

matherp

Senior Member
This works for me on 28X1-A.5 but just for info the dirsc command is redundant. low portc x and high portc x automatically set the ports as outputs. Check your voltage supply, LEDS can be on but not lit if there is insufficient voltage across them.

Regards

Peter
 

Mikler

Member
My apologies for wasting your time. Problem is solved.

Mik

(By way of explanation, I am normally running my circuit at 3 volts, driving the leds directly with no series resistors. In error, I have been recently running it at 4.5 volts - while the normal outputs where OK with it, the configurable inputs/outputs did not like it.... back at 3volts, all is well! Sorry!)
 
Top