CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ICD-U40 Debugger Monitor with real RS232

 
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go
View previous topic :: View next topic  
Author Message
RoProe



Joined: 03 Mar 2005
Posts: 6

View user's profile Send private message

ICD-U40 Debugger Monitor with real RS232
PostPosted: Thu Mar 03, 2005 6:12 am     Reply with quote

Hello,

i use the 16F877 (4MHz) with the ICD-U40.

In my Programm, there ist a real RS232 mit the internel UART and i use Software FIFO on this UART. With Interrupt at receive an send.

For Debug info i want to use the RS232(DEBUGGER) with ICD and the Monitor Window.

The Debug-Output works very well. But if i receive any charecter on the real UART, the Debugger send only ")%/&%/&" ans o on.

Is there any Problem to use UART and Debugger at the same time?

RoProe
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Mar 03, 2005 8:48 am     Reply with quote

Look up #use RS232 in the manual. Look at the invert function.

If you use the internal UART, you need a level translater (max232) before it is run to the PC serial port.

If you don't use the UART, then you can use the invert function and a 1k resister in series right into the serial port pin2or 3.

For a test change the pin used so its not the uart. Then put in the resister, add the invert code and see what comes out.
RoProe



Joined: 03 Mar 2005
Posts: 6

View user's profile Send private message

PostPosted: Thu Mar 03, 2005 9:19 am     Reply with quote

That isn't the problem.

The real UART is use with MAX232 and it works every Time.

The "#use RS232(DEBUGGER)" works with problems. If there is a interrupt from real uart, the "#use RS232(DEBUGGER)" write only stuff.

RoProe
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Mar 03, 2005 5:14 pm     Reply with quote

I don't have a CCS ICD to test, but this may help:

The CCS compiler uses a software UART on Pin B3 to send out
the DEBUGGER characters. If you get an interrupt when a character
is being sent out, then the timing of the RS232 pulses on pin B3
will not be correct. To fix this, you need to disable interrupts when
you're sending data out on the DEBUGGER pin. See the example below.

Of course, if you disable interrupts for too long, this may cause
other problems in your program. For example, you could miss
incoming characters in your #int_rda routine.

Code:
#include <16F877.H>
#device CCSICD=TRUE
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#int_rda
void rda_isr(void)
{
char c;
c = getc();
}

//============================
main()
{
printf("Hello World");

#use rs232(DEBUGGER)
disable_interrupts(GLOBAL);
printf("ABC");
enable_interrupts(GLOBAL);

while(1);
}



-----------------------
Edited to add:

To solve the problem of interrupts being disabled for "too long"
when the DEBUGGER software UART is used, I created the code below.
With this code, the interrupts will only be disabled for one character
time period when the DEBUGGER output is used. In between each
character, interrupts will be re-enabled. This will allow the hardware
UART interrupts to occur and you won't loose incoming characters.

Code:
#include <16F877.H>
#device CCSICD=TRUE
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#int_rda
void rda_isr(void)
{
char c;
c = getc();
}

// Function Prototype
void debugger_out(char c);

//============================
main()
{
printf("Hello World");

printf(debugger_out, "ABC");

while(1);
}
//==================
// The printf(debugger_out, "ABC") statement will send
// characters to the following routine, one at a time.
// It will send 'A', then 'B', and finally 'C'.    So now,
// interrupts will only be disabled for one character time
// period. 

void debugger_out(char c)
{
#use rs232(DEBUGGER)
disable_interrupts(GLOBAL);
putc(c);
enable_interrupts(GLOBAL);
}
Guest
Guest







RS-232 with debugger
PostPosted: Mon Mar 07, 2005 5:13 pm     Reply with quote

I am trying to dend data over the RS-232 port while simultaneously sending the data to the debugger window using the ICD-U40. Will your code do this? How does the microcontroller know to switch to and from the debugger? Do you have to say

Code:

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
printf("Serial");
#use rs232(DEBUGGER)
printf("Debugger");
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
printf("Serial");
...


To switch back and forth between modes? In the previous code you have only one call to change the communication to the debugger. Does it somehow automatically change back to the RS232 port? Are you just assuming the user is using an ICD-S40 instead of a U40 and he wants to write to the Debugger window?
Guest
Guest







RS232 with Debugger
PostPosted: Mon Mar 07, 2005 5:42 pm     Reply with quote

Ok, to answer my own question, the above code does work.

Now I have another question. Does switching between modes like this cause any significant performance delays / problems besides the interrupt problems discussed earlier?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 07, 2005 9:23 pm     Reply with quote

Each you have a #use rs232(DEBUGGER) statement, the compiler
generates code for another instance of the software UART.
Each instance takes about 38 ROM words in the .LST file.

That's why it's better to use one "access" routine, as in my example,
and send the string to it with the special CCS feature that lets you
re-direct the output of printf to a routine.
dilandau



Joined: 25 Aug 2010
Posts: 11

View user's profile Send private message

PostPosted: Wed Sep 21, 2011 9:27 am     Reply with quote

What I would do to check solve this problem:


1 - check you have #device ICD=TRUE fuse

2 - check there is a IO pin connected to ICD pin6 (for debugging)

3 - check that pin to be the one you use in the use232.
I use it this way. In my case PIN_B5 is the one for monitoring. (using CANBUS developer from CCS)

Code:
#use rs232(debugger,STREAM=MONITOR, baud=2400,xmit=PIN_B5,rcv=PIN_B5)


4 - Enable data acquisition for PICC monitor. In the "Debug Configure" tab, set "userstream enabled" to "true"
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> CCS ICD / Mach X / Load-n-Go All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group