Quote:
Ivo made the fastlib library so it generates during compiling a most efficient way of controlling the hardware (note: not the easiest..)
Oh I got that, I can imagine that especially for something like this you can use all the speed you can get, but it just makes it a bit harder to understand if you are not into it.
Anyway because I am a bit bored I decided to compile for myself. After some issues (had to change file name to cpp, and obviously my debug serial port wont do much with all peripherals turned off), it ran, and I noticed exactly the same as you had. After some checking of registers pretty much everything seemed fine, and obviously I missed the issue. So then I started turning stuff off in the VGA library, and indeed the hsync function was the issue, to be exact the fl_pinsel.
After that it was looking a bit more, and as you have quite often (well at least I have it), in the end it was pretty obvious. The call of fl_pinsel is wrong. The error is that the library uses FL_FLOATING as parameter for the opendrain state. That definition is (I think, but pretty sure) only intended to be used by the pull up/down state. FL_FLOATING has as value 2, open drain is 1 bit per pin, so the function sets the value 10 in location 1 of the register (where it intends to write 0 to disable open drain), which overflows into location 2, setting it to open drain mode. Now port 2 bit 2 is open drain, which is p24.
So the solution is simply replacing:
fl_pinsel(2, 1, FL_FUNC_ALT1, FL_FLOATING, FL_FLOATING); // PWM1.2, no pullup/down
With either:
fl_pinsel(2, 1, FL_FUNC_ALT1, FL_FLOATING, FL_DISABLE ); // PWM1.2, no pullup/down
or
fl_pinsel(2, 1, FL_FUNC_ALT1, FL_FLOATING, FL_IGNORE); // PWM1.2, no pullup/down
Sorry, wrong port pin in header: pin 24 is reading low not p26.
I am trying to use pins p21,p22,p23,p24 and p26 as inputs using the standard setup DigitalIn(pin)
I also enabled PullUp mode for these pins but when I enable the double edge PWM output (VGA library) on p25 then p24 always reads '0' (low)
A small program without the VGA/PWM stuff works OK, in the VGA code I can only find one f_pinsel function for the PWM output pin setting (Port2 bit1) so what might be causing this ?