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

I can't get familiar with PUTCHAR and PUTS

I've got a problem. I've posted it yesterday but it was probably lost in text.

static void Nastav_seriovy_kanal (void)
{
	SCON = 0x50;
	TMOD = TMOD | 0x20;
	TH1 = 0xF4;
	TL1 = 0xF4;
	ES = 1;
	TR1 = 1;
}

static void Preruseni_seriovy_kanal (void) interrupt 4
{
	if (RI == 1)
	{
	    RI = 0;
	    if(SBUF == 'A') putchar('Q');
	}
	if (TI == 1) TI = 0;
}
I'm also including stdio.h, and string.h(string.h is not necessary).

Does anyone have any idea why it doesn't work?

Parents
  • In my opinion and I hope it's clearly said in that source code I've posted,

    It doesn't say anything in your source code, as there are no comments. Someone who actually goes through the trouble of trying to understand the source code might figure it out. However, please be aware that understanding uncommented source code is very difficult - and even more so for someone who is not the author of the code.

    That aside, let's look at the problem.

    Did you set a breakpoint in the ISR to see if it is actually called ? Your code excerpt does not show the EA bit being set anywhere, but I would guess that you've thought of that and do it somewhere else in your code.

    Did you have a look at the source code of the putchar function ? It should be in C51/lib somewhere.

    Do you call putchar() from anywhere else in the program ? The function is _not_ reentrant, so if you call it in the normal program and in an ISR without taking some precautions, problems are pretty much guaranteed.

Reply
  • In my opinion and I hope it's clearly said in that source code I've posted,

    It doesn't say anything in your source code, as there are no comments. Someone who actually goes through the trouble of trying to understand the source code might figure it out. However, please be aware that understanding uncommented source code is very difficult - and even more so for someone who is not the author of the code.

    That aside, let's look at the problem.

    Did you set a breakpoint in the ISR to see if it is actually called ? Your code excerpt does not show the EA bit being set anywhere, but I would guess that you've thought of that and do it somewhere else in your code.

    Did you have a look at the source code of the putchar function ? It should be in C51/lib somewhere.

    Do you call putchar() from anywhere else in the program ? The function is _not_ reentrant, so if you call it in the normal program and in an ISR without taking some precautions, problems are pretty much guaranteed.

Children