View previous topic :: View next topic |
Author |
Message |
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Wed Mar 30, 2011 2:37 am |
|
|
I forgot to say I'm using mplab icd 2 to debug the code |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Wed Mar 30, 2011 5:09 am |
|
|
I'd have expected it to start working with the larger (32character) buffer.
Problem is that when 'temp==1', you may not 'see' this for the time taken to execute three tasks - how long do these take?. You need to use the debugger and _time_ the total these take to execute, and then you send 9 bytes (why not just use 'putc("ABCDEFGHI";', or a printf?), _before_ you start looking for the next packet in your code. Also, you don't show the code setting temp _back_ to zero. This should be the first line after the 'if (temp==0)' test. Now with the 32 character buffer, you can receive 18 characters after 'temp' is set, before an effective overflow would occur.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Wed Mar 30, 2011 6:00 am |
|
|
I see the problem only when it executes putc function. I have done:
Code: |
while(TRUE) {
StackTask();
UDPTxTask();
UDPRxTask();
if(temp==1)
putc('A');
temp=0;
}
|
and the problem arises. However if I do something like :
Code: |
int p;
while(TRUE) {
StackTask();
UDPTxTask();
UDPRxTask();
if(temp==1)
p=5;
temp=0;
}
|
I have no problem at all. The problem comes up only if I use putc. Thats why I was wondering the thing has to do with full duplex comm settings, directive #use rs232 or my MAX488. Maybe a new PIC? |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19366
|
|
Posted: Wed Mar 30, 2011 7:15 am |
|
|
Use ex_stisr.c.
Serial interrupt driven _transmit_ buffer.
Then your code only needs to load the output data, and the interrupt sends it.
Whatever you do though, the sequence should be:
Code: |
if (temp==1) {
temp=0;
//Now read your data from the buffer, and send your reply data
}
|
You need to acknowledge that you have seen the characters ASAP.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Manel28
Joined: 06 May 2010 Posts: 33
|
|
Posted: Fri Apr 08, 2011 3:44 am |
|
|
I solved the problem. I dont know why but it seems to work when I write the byte in TXREG rather than use putc. I used as well driven transmit buffer. I did something like:
Code: |
#int_tbe
void tbe_isr() {
if(temp==1){
TXREG=interbuff[next_out];
next_out++;
if(next_out==lenbuff){
next_out=0x00;
temporizador=0;
disable_interrupts(INT_TBE);
}
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9173 Location: Greensville,Ontario
|
|
Posted: Fri Apr 08, 2011 5:17 am |
|
|
You should add the option 'errors' to your use rs232(...)...
also I don't know if 8 bits and Odd parity is 'legal' for your PIC/compiler. |
|
![](templates/subSilver/images/spacer.gif) |
|