Hi!
Here you have a sample code with a 16F877 but from C language:
http://www.dunmire.org/projects/MEEPS/software/level.cMore info about ADXL202:
The ADXL202 outputs a PWM with 8ms periode. At 0 degree is puls / pause =1/2 (pulse 4ms / pause 4ms). If now the sensor is +90 degree (pulse 7ms / paus 1ms) and at -90 degree (pulse 1ms / pause 7ms). You can calculate the angle of the sensor with: x=(puls:pause)*var
Use your TMR0 counter and INTCON timer prescaler bits to set up an interrupt routine which at precise intervals samples the PIC input (ADXL202 output) pin for a high or low (1 or 0). Since you are working with ratios, just count the total of 1's and divide by total 0's, or vice-versa if required, to determine your angle. You can do some error checking by counting the total of 1's and 0's.
Or...since you know the the total period is 8ms, you can just count the number of 1's with a known interrupt interval and calculate.
Or....some PIC's have an edge-triggered hardware interrupt on some pins. When your pin goes high, do the interrupt routine by starting an internal timer, sampling the pin until it goes low. Your timer count at that point should give you enough information to make calculations, which you will have to do during the low pin time.
Regards,