IDLE fluctuating? TDC?

a while back, my alternator went out and i replaced it as well as the battery. a few weeks later, out of no where my car started idling weird. it would idle too high during warming up and would drop and go up again. then when the engine was warm, it would normally idle from regular to around 1500 and drop again. it would occationally stop, but when it did, it idled at about 1200. sometimes when it would fluctuate, i could compensate the idle with turning on my lights. after i turned on my lights, it would stop. i checked my engine codes and i’m throwing a code 8 and a code 22
from what i understand, 8 is TDC sensor. would that mean my timing on my cams were off? would it have to do with my code 22 vtec pressure switch? also i checked the codes late at night and now that i think of it, the code might be a 7, and 7 is TPS. would a bad tps cause the idle to fluctuate? please enlighten me. thank you for your help