We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
I am having two problems which I think are pretty much related to each other:
Problem 1: passing parameters to function called from ISR
I am invoking a function from ISR. To this function, I pass a variable (unsigned char). When the function is invoked, the value received in the function is zero! If the same function is called from main (), then the value received = the value passed. What am I missing ? How to rectify this problem, besides use of global variables to pass the data (this work around I am already using).
Problem 2: function called from ISR does not behave as intended
There is a delay function that I invoke from the ISR (void delay_6ms()). I have simulated the code on KEIL, which shows that the delay introduced by this function should be to the tune of 6 msec. When I invoke it from ISR, the delay is about 320 usec, however, when I invoke it from main (), the delay is about 4 msec. Why the difference ? Why main() does not give 6 msec delay ?
If I declare the variable inside the function as static (i and j), the delay in ISR changes to 1.4 msec. I tried to declare the function reentrant to see the effect, but there was no change.
--------------------------------------------------- void delay_ms() { unsigned char xdata i; unsigned char xdata j;
i = 0;
while(i++ < 25) { j++; }
i = 0; }
void delay_6ms () { delay_ms(); delay_ms(); delay_ms(); delay_ms(); delay_ms(); delay_ms(); } ---------------------------------------------------
This function should give 1 msec delay, and if called multiple times, then should give a delay in proximity to the number of times it is called.
Regards Aman
you cannt acuretely simulate writing to EEPROM because the time you need to write is variabible so you must look at datashit for worst timing for a write so you can see how long it will take for the ISR lag but how long have you got for the ISR lag becoz if it is not long enough you will not have time to write all of youre data to the EEPROM and you will not have good data if you caal function from ISR you might use 'dont use absolute register accesses' option in compiler options bcoz else compiler assumes register bank for direct access to register but might be wrong register if ISR has using something else