toggle command on pinsC using 28x1

hal9000

Member
I am trying to use the toggle command on the second output port (after setting up with dirsc=$FF) on a 28x1...

The thing is, i'm pulling my hair out, while you can use 'toggle x' where x is 0 to 7 for the first output port, i can't see any way of using the toggle command to manipulate pins on the second output..

I need to literally toggle the output pins individually, i can't make do with just writing a byte value to the whole port in order to change the outputs...

I must be missing something basic here, i've gone through the basic manual, and searched the forum but can't find the answer.. while my 40x1 is refusing to be programmed, i wanted to harness the 16 ouptus of the 28x1, but i'm being thwarted on my attempts so far! :)
 

inglewoodpete

Senior Member
Yep, you're on to it! Port C has several 'features'. One is both input and basic output capability. Another is that some pins have special capabilities, depending of the chip used: Serial In/Out on side-by-side pins, ADC, PWM, SPI etc. Unfortunately, one of the limitations is that some commands that work on all output pins (Toggle, PulsOut, SerOut) will not work on all Port C pins.
 

hal9000

Member
For anyone interested by this thread, I managed to work around this problem by assigning a byte variable as a shadow of the portc in essence, then i Xor'd the bitmask of the output pin i wanted to toggle and wrote the byte variable to the port after the xor 'toggle' operation.

I thought this might impact timing and the visual effect i was looking for, but it seems that it works fine, code example below:
Code:
symbol outc = b0

dirsc = $ff
let outc = $ff

main:
let outc = outc xor $01      'toggle bit 0 (output 0)
outpinsc = outc
pause 500
outc = $00
let outc = outc xor $01      'toggle bit 0 (output 0)
outpinsc = outc
pause 500
let outc =$ff

goto main
Just replace the xor value with the powers of 2 to set the corresponding bit ($01,$02,$04,$08,$10,$20,$40,$80)

I'm still learning, maybe this might help someone. Its a bit annoying that portc has this sort of limitation.

On a related note, would you happen to know if the 40X1 has similar problems with re-assigned output pins?
 
Last edited:

hippy

Ex-Staff (retired)
All PICAXE's have the same problems with anything other than their 'standard output pins', that is those which are accessed using PORTC can only have individual pins set high or low, or the whole port written using 'pinsc'.

It's one of the issues of limited memory within the devices PICAXE's are built from and keeping life simple for users moving between PICAXE types. The 28X2 and 40X2 when they arrive will I believe allow access of any kind to any pin.
 

hal9000

Member
Ok, now i have working 40X1's in my setup, how can i use the extra outputs on this chip? The programming editor wont listen to anything when you refer to portB, pinsB, dirsB, or anything for D, am I limited to just the same two output ports that the 28x1 has? ie portA and portC ?
 

Technical

Technical Support
Staff member
Please the appendix at the end of the manual part1. It explains the configuration options available.
 
Top