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 CCS Technical Support

Interruption priority problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Manel28



Joined: 06 May 2010
Posts: 33

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 2:37 am     Reply with quote

I forgot to say I'm using mplab icd 2 to debug the code
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 5:09 am     Reply with quote

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
Manel28



Joined: 06 May 2010
Posts: 33

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 6:00 am     Reply with quote

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?
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 7:15 am     Reply with quote

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
Manel28



Joined: 06 May 2010
Posts: 33

View user's profile Send private message

PostPosted: Fri Apr 08, 2011 3:44 am     Reply with quote

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);
        }
    }
}
temtronic



Joined: 01 Jul 2010
Posts: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 08, 2011 5:17 am     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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