I am using a 18F2550.

I seem to have it working at the moment however it is not very smooth.

When the on/off button is pressed I need to sweep from 0% duty cycle up to the set limit in 1 second. I can see this happening by writing the incremental counter results to EEPROM and reading them later, however, the duty cycle does not increase for every +1 increase of the duty cycle byte. I assume this is a resolution issue due to running at 48MHz?

I really need to smooth that out and give a very nice gradual increase in light over time.

Also, what is a good way to have the program wait for a pin to go high?

Currently I am using:

waitforon:
If PORTB.7 = 1 then 'on/off button pulled high = on
gosub rampup 'increments final_duty and outputs value to CCP1
endif
PORTC.0 = 1 'flash heartbeat LED
pause 100
PORTC.0 = 0
pause 100
If final_duty = limit then 'if returned to waitforon from rampup, then final_duty is at set limit, so move on to main program
goto main
endif
goto waitforon


Sometimes this will not move to rampup: or move on to main: but the heartbeat LED will always flash correctly.