MC9S12 is not enough. You should mention letters past 12, for example S12C, S12XD etc. S12XD RTI has decimal clock prescaler mode, older families don't have such mode, etc.
Your code has few bugs:
1) You should reset count in ==500 case,
2) you are not toggling port pin, but pulsing it high for less than microsecond.
3) pin pulsing period is going to be 501 RTI periods. When count reaches 500 and you reset it, you exit ISR. But when you reenter ISR one RTI period later, this one period is not counted. So either chnge your code to if(count == 500-1) or maybe change the logic like this
isr()
{
count++;
if(count == 500)
{
PORTE ^= (1<<4);
count = 0;
}
}
4) The ay you clear RTI flag has side effects, which certainly will bite you sooner or later. You are clearing all flags in CRGFLG register, not just RTIF. To clear only RTIF you shoud CRGFLG = CRGFLG_RTIF_MASK;
If you are going to toggle pin on port T, then why are you pulsing pin port E?
Does that make the LED toggled approximately every 0.5s?
If so, how do you keep track of the elapsed time?
Do you mean how to count seconds? The's number of ways to do this. You may sum all milli- and microseconds like 1024us+1024us+ etc and convert microseconds to seconds and minutes. You may also try to find prescaler so that integer number of RTI periods will take exactly 1s. For this at 16MHz oscilator clock 1024 and 5120 prescalers are available. 5120 presclaer gives RTI period if 320us, 320us *3125 = 1s.
How do you use a modulus counter to provide a periodic intterupt every 2ms?
I know how the modulus counter works but i don't know how long the system will
take to count for example from 100 counts to 0.
Do you mean you don't know what clock modulus down counter is operating at? It's bus clock (which is half of oscilator clock).