Hi goaran,
Regarding the code you posted, I'd recommend this:
- always use the defines in system.h instead of numeric addresses
- always use IORD/IOWR macros to access pio registers; I had similar situations where the trick with pointers didn't work (I'm not sure why)
Regarding the two segments always on, this depends where they are actually connected. If you use an input, the level is not well defined: a pull up/down on the signal can alter the signal level. I suggest you connect them to outputs or hardwire them to Vcc or gnd inside fpga.
Cris