EMX port pins


trying to set cobra (EMX) LPCxxx port 1.6 pin as output hi & low.& hi & lo…tried this nothing happens…any thought? … This port pin is avail at the SD card pins & am using it fine for PWM already PWM0[4], but in some cases I just need a high or low

    static Register IO1DIR = new Register(0xE0028018);
        static Register IO1SET = new Register(0xE0028014);
        static Register IO1CLR = new Register(0xE002801C);

 Debug.Print("port test");
                                       PINSEL2.ClearBits(3 << 12); // set to I/O port mode
                                       uint portdir;
                                       portdir = IO1DIR.Read(); //GET OTHER CURRENT PORT PIN DIRECTIONS
                                       portdir = portdir | (1 << 6);  //set p1.6 as output

                                       IO1CLR.Write(1 << 6);  //set low   
                                       IO1SET.Write(1 << 6);  //set high  
                                       IO1CLR.Write(1 << 6);  //set low   
                                       IO1SET.Write(1 << 6);  //set high  

good thoguth, but NO:

P1xDIR 0
Slow GPIO Direction PORTx control bits. Bit 0 in IOxDIR
controls pin Px.0, bit 31 IOxDIR controls pin Px.31.
0=Controlled pin is an input pin.
1=Controlled pin is an output pin.

hmmm…maybe they have it listed backwards…will try clearing it for fun…any other thoughts?

Yeah I checked it and I was wrong. That’s why I deleted my post.

I’ve checked addresses and bits, all seems correct. Can you read out PINSEL2 after your test and verify that bit 12 and 13 are still cleared?

Also, double check that you’re measuring on the correct pin :wink:

I’m 99% sure I’m on the proper pin, since I do working PWM there…just need a way to force the pin high at times (want try low also, so I know I’m really controlling it & its not high due to some random setting).

When I set pinsel bits to 00 it goes high since I believe the pullups are on by default & it is set to direction input…so I’m not really in control.

Btw if you’re doing pwm, why not use a dutycycle of 100% or 0% to set the pin high or low?

hey–that’s interesting…do you know if it can do 0 &100%? Not all chips can…I’m really doing double mode timing, but its eassentiually pwm…set when it goes high, when it goes low

I’ll be looking into this!

Software pwm can fail on this, but for hardware pwm, this is no problem.

I was still wondering why my posted code is not toggling the pin…seems rather strange…I wonder if something additional needs adjusted (in some unknown register, like port activation,ports disabled, etc)…This chip has more setup pregister than anything I’ve ever seen

Do you think I need to use the “high speed” I/O registers? I do not want high-speed, just be able to to turn the pin high and low (sloooooow…)