Picaxe40X - portC Output problem

kenmac

Member
I've just moved up to a 40X, using it to drive a parallel LCD, among other things.
Initially I set it up to use the first 4 Output pins for the LCD data, and two portC output pins for the RS and EN lines.
The EN pulse is supposed to be short and so it was programmed as "high portC 2", followed immediately by "low portC 2".
This is effectively a "toggle" action, expected to result in a very short pulse.
The LCD didn't work, so I checked it out with a CRO and found that the EN pulses were a lot longer than expected - measured about 300uSec!
Is there some sort of timing penalty when using the portC pins as outputs?
I tried using the Pulsout and Toggle commands, but apparently they aren't allowed in his case.
I managed to get it working using Output pins 4,5 for RS and EN, but I wanted to use the lower group of 4 Output pins for another function.
I know I could use a serial LCD, but this would require a purchase, whereas I have a parallel one on hand.
The Manual needs to be a bit clearer re the Toggle/Pulsout and portC on the 40X.
There may be some relevant info there that I have missed?
 

hippy

Technical Support
Staff member
The 'timing penalty' comes in having to do a HIGH then LOW rather than using PULSOUT. The HIGH-LOW sequence would take the same time and give the same length pulse on the normal outputs as it does on PORTC outputs. The ~300uS is the time it takes after executing HIGH to load the LOW command, decode it and execute it.

I'm not sure why you had problems using a PORTC Output for EN because it should work. I haven't experienced a problem with EN being too long, but it is possible. You could replace the PULSOUT with HIGH-LOW on the current Output and see if that also affects it, and if it does will demonstrate it is timing sensitive.

If it however works, try moving the EN line to PORTC again to see if it keeps working.

If not, perhaps there are other things going on which interfere with PORTC operation, cut the code back to an absolute bare minimum and get that working if you haven't already.
 

kenmac

Member
I checked the High/Low action on the standard Output, and it reacts similarly - i.e. result is a pulse of about 300uS.
Using "PULSOUT pin, 1" gives the required result of a very short pulse, and the LCD works OK with that.
Obviously, the LCD doesn't like 300uS long pulses for the Enable function.
Previously I have used the same LCD with PIC's (16F84) and the result of using High/Low there is a short pulse.
I suspect that it has more to do with the interpreting actions than the actual workings of the Picaxe chip.
Anyway, the reality is that PortC pins can't be used for this particular function, so I have to use the standard Output pins and reorganise the overall pin allocations.
It seems that the PULSOUT function only applies to the standard Output pins - that info doesn't seem to appear anywhere in the Manual.

Ken Mac
 

hippy

Technical Support
Staff member
This could be something which is LCD manufacturer dependant. I'd previously used HIGH-LOW before realising PULSOUT was better, and I've even put mS delays between while debugging with a LED to check the line was pulsing with no adverse effects. Putting a parallel LCD on PORTC has been discussed on the forum before and I don't recall anyone coming back and reporting such problems.
 

kym

Member
If i am reading this correctly ,you are using
4 pins of portB for the data, and 2 pins of portC for the enable lines, when first trying to move my LCD from portB to portC I did manage to achieve this but putting them all on the same port is a much easier solution.
either portB or PortC .

Removing some of the pause lines should also help.

The the manual is not much chop , when it comes to portC commands as most of the
commands that work for portB will give
syntax errors on portC .

Kym
 

hippy

Technical Support
Staff member
The only valid commands for use with PORTC are ...

HIGH PORTC <i>pinN </i>
LOW PORTC <i>PinN </i>
LET PINSC = <i>value/variable </i>
LET DIRSC = <i>value/variable </i>
LET TRISC = <i>value/variable </i>
IF PORTC <i>PinN </i> <i>comp </i> <i>value/variable </i> ...

I'm sure it says somewhere in one of the manuals that other I/O commands only work with the 'default I/O pins' and not PORTC, but I cannot say exactly where.

&quot;LET TRISC&quot; is only available for the 28X/40X.

Additionally, where PORTC pins are the 'default input pins', as on the 20X, any digital input command ( PULSIN etc ) will use that PORTC pin. There is no need for any 'PORTC' keyword as the compiler knows these are the default input pins.

Edited by - hippy on 23/04/2007 15:55:33
 

kenmac

Member
Thanks Hippy.
Perhaps the manual could have a mention re the non-availability of a particular command for 40X PortC.
e.g.&quot;PULSOUT.... (not available for 40X PortC)....&quot;
Even better would be to have the Editor's Syntax Checker provide an explanation window when the associated error occurs.
Anyway, I have made a note for future reference and re-organised the I/O pins to suit, and it works OK now.
I think I'll convert my remaining LCD to &quot;serial&quot; operation, using a redundant PIC.
That will ease the pressure on the number of I/O pins required for future projects and will allow the use of smaller/cheaper Picaxes.

kenmac
 
Top