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

bgetc circular buffer stop

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Manu59114



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

bgetc circular buffer stop
PostPosted: Tue Apr 03, 2018 8:58 am     Reply with quote

Hello to all,

I use the circular buffer from the CCS example to receive data from the uart and everything is fine except at one moment.

If i stop sending data to the receiver and the middle of the transmission. (sent only 5 characters for example)

The receiver stop exactly just before this instruction:
Code:

Receive_Array[numero_case_dans_tableau] = bgetc();
 

The PIC is not crashed but waiting for something somewhere but i don't know what and where!!
Timer 0 is not counting....

At this moment, if i turn on the data from the sender, the receiver back the live!
Code:

If(next_in!=next_out)
  {
   printf("A\r"); // to test 

   If(bgetc()=='*') // Aller récupérer un caractère dans le buffer "bgetc()" et le comparer avec 0x2a ou '*'ascci
     {
      do
        {
         printf("B\r"); //to show where i'm in the function

         Receive_Array[NCDT]= bgetc();

         // mettre ce caractère dans la prochaine case du tableau. c'est à dire la case 0
         Receive_Array[NCDT]=data_from_circular_buffer;

         NCDT++; // incrémenter. ajouter 1 à NCDT
        }
      while(NCDT!=NCDT_Default); //  NCDT_Default == 49

      NCDT=0; // case tableau à 0
     }
  }

Treat_Data_Array();

Do you have an idea where it is blocked?

Thank you very much to all.

MAnu
_________________
CCS + ICD3 + PIC18F46K80
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Tue Apr 03, 2018 10:55 am     Reply with quote

Bgetc, will wait if there is no data available. So you need to test if (bkbhit), before calling it, or the code will hang.
Manu59114



Joined: 22 Jan 2018
Posts: 34
Location: North of France

View user's profile Send private message

PostPosted: Tue Apr 03, 2018 3:20 pm     Reply with quote

I changed like this and the problem still the same!

Is it the right place to test Bkbhit ?
Code:

If(next_in!=next_out)
  {
   printf("A\r"); // to test 

   If(bgetc() == '*') // Aller récupérer un caractère dans le buffer "bgetc()" et le comparer avec 0x2a ou '*'ascci
     {   
      do
        {
         if(bkbhit)
           {
            printf("B\r"); //to test
                                  // get the next character
            Receive_Array[NCDT] = bgetc();

            // mettre ce caractère dans la prochaine case du tableau. c'est à dire la case 0

            Receive_Array[NCDT] = data_from_circular_buffer;

            NCDT++; // incrémenter. ajouter 1 à NCDT
           }
         else
           {                                                                                 
           }
        }                                             
      while(NCDT != NCDT_Default); //  NCDT_Default == 49


      NCDT=0; // array position at 0
     }

  }

Treat_Data_Array();


Thank you to all.
wish you a great day.
_________________
CCS + ICD3 + PIC18F46K80
alan



Joined: 12 Nov 2012
Posts: 349
Location: South Africa

View user's profile Send private message

PostPosted: Wed Apr 04, 2018 12:58 am     Reply with quote

When do you think you will exit this loop with no data arriving.
Code:
while(NCDT != NCDT_Default);
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion 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