after reset, terminal window prints garbage

Here’s a question: What does DOWNLOADING do that RESET does not do?

Here’s the story:

After I download new code, the code starts running and printf-ing to the terminal window – everything is fine.

If I press RESET on the RC, the terminal window continues to show output, but it’s unreadable – instead of letters and numbers there are weird symbols and other characters.

The rhythm of the output is unchanged (I only printf() stuff every 20th cycle, so it’s about twice a second). But it’s unreadable junk – garbage.

Downloading again (the same code or different) clears up the problem until the next RESET. But that’s not a solution, it’s just a clue.

What does DOWNLOADING do that RESET does not do?

What’s going on?

I’ve searched the archives and found someone with the same problem, but there was no answer.

Which serial port code are you using?

I’m using <stdio.h> and not “printf_lib.h”. Is that what you meant?

My InterruptHandlerLow() is the usual:


void InterruptHandlerLow ()     
{
	if (PIR1bits.RC1IF && PIE1bits.RC1IE) // rx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_RX
		Rx_1_Int_Handler(); // call the rx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.RC2IF && PIE3bits.RC2IE) // rx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_RX
		Rx_2_Int_Handler(); // call the rx2 interrupt handler (in serial_ports.c)
		#endif
	} 
	else if (PIR1bits.TX1IF && PIE1bits.TX1IE) // tx1 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_ONE_TX
		Tx_1_Int_Handler(); // call the tx1 interrupt handler (in serial_ports.c)
		#endif
	}                              
	else if (PIR3bits.TX2IF && PIE3bits.TX2IE) // tx2 interrupt?
	{
		#ifdef ENABLE_SERIAL_PORT_TWO_TX
		Tx_2_Int_Handler(); // call the tx2 interrupt handler (in serial_ports.c)
		#endif
	}
}

I’m not sure exactly how the various ENABLE_SERIAL_PORT_xxx_xx macros are set (I don’t have a copy of the code with me) – I’ll have to check. But even if all four were enabled, that should not do bad things, should it?

And why should the startup conditions after download be different than after a reset?

when downloading code, the baud rate is set by the download control. at the end of the load, the serial port is left at the download rate.
after reset, you must properly set the baud rate in your code. it sounds like the serial port init is not running in your code.

jerry w

That sounds very likely. I will check it at my next work session (Thursday).

Thanks!