This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

printf corruption while called in a sunroutine with inrelated interupts running

I'm having a major problem with printf. The code is set up so that the printf's are used in subroutines, 1 maybe 2 deep. There is a separate RTC routine running that has nothing to do with the printf subroutines.

Here is the problem,

if the interrupt is off printf works OK,

if the RTC interrupt is running, the printf prints a few characters correctly then takes off in an endless stream of garbage, but repeating pattern. The printf never returns once this starts.

Here is what has been done,

printf's pointer requirements have been minimize by breaking complex lines into separate lines

RTC interrupt rate has ben reduced, in case there was a cpu speed resource issue

Xdata ram reserve has been increased to 700 bytes.

I suspect there is some sort of ram conflict occurring, but I am having no luck in figuring it out. Has any one seen the printf source code.

The only solution will be to write a totally new printf, but this si a big job with teh format specifiers and there is likely not enough memory.

any help appreciated

Parents
  • Also found bug in compiler relating to setting the TCON SFR while in a subroutine.

    It's highly unlikely that the C51 compiler has a bug that directly affects TCON, or a bit within it.

    I'd say, from what you're describing, that it is possibly a function overlay issue; with the variables of the mainline code and interrupt maybe using the same memory locations. Check the MAP file to determine variable addresses for mainline and ISR use.

    Treat comments about the use of using carefully. Using register banks is not always the clear winner, and not using them can allow the compiler (and you) to carry out other optimizations.

Reply
  • Also found bug in compiler relating to setting the TCON SFR while in a subroutine.

    It's highly unlikely that the C51 compiler has a bug that directly affects TCON, or a bit within it.

    I'd say, from what you're describing, that it is possibly a function overlay issue; with the variables of the mainline code and interrupt maybe using the same memory locations. Check the MAP file to determine variable addresses for mainline and ISR use.

    Treat comments about the use of using carefully. Using register banks is not always the clear winner, and not using them can allow the compiler (and you) to carry out other optimizations.

Children