problem with large array

This is a discussion on problem with large array within the C Programming forums, part of the General Programming Boards category; Hai, My serial interrupt routine collects all the data from the serial buffer (Controller) successfully, the data sent from the ...

  1. #1
    Registered User
    Join Date
    May 2008
    Location
    India
    Posts
    11

    problem with large array

    Hai,

    My serial interrupt routine collects all the data from the serial buffer (Controller) successfully, the data sent from the controller never exceed more than 2000 bytes.
    The problem is when the controller sends large no. of bytes for eg 400 bytes, the array "RecBuffer" holds all the bytes successfully but when i look at the array RecBUffer after the interrupt routine or at the end in the interrupt routine as i posted below, The data inside the array is different, what manipulation do i need to make in order to make the content remain the same until its is over wriiten.

    This above case is not the same for fewer bytes sent, the content is not altered.

    Code:
    #define ETX 3
    unsigned char RecBuffer[2048];
     unsigned short count;
    void interrupt (*oldport1isr)();
    
    void interrupt PORT1INT() /* Interrupt Service Routine (ISR) for PORT1 */
    {
         unsigned int c;
        do
        {
            c = inportb(PORT1 + 5);
            if (c & 1)
           {
    
                  RecBuffer[count] = inportb(PORT1);
                 printf("data %x",RecBuffer[count]);
                 count++;
                 if (RecBuffer[count-1]==ETX){
                        count=0;
                       printf("RecBUffer[0]=%x ",RecBUffer[0]);// to look at the array content at the end of data collection
                 }
           }
      } while (c & 1);
      outportb(0x20,0x20);
    }
    i work on dos, compiler turbo c
    many thanks for any help
    Last edited by supi; 07-02-2008 at 09:15 AM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    Look up your references as to what is valid to call inside an ISR.
    You have a very restricted set of functions you can call inside an ISR, and printf() isn't likely to be one of them.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    May 2008
    Location
    India
    Posts
    11

    the problem resloved

    I changed the below array

    Code:
    #define ETX 3
    unsigned char RecBuffer[2048];
    to


    Code:
    #define ETX 3
    unsigned char huge RecBuffer[2048];
    as i mentioned. i am working in dos environment, in here to access the data beyond 64 KB we need 32 bit pointer, hence huge pointer was required.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Putting INTs Into a CHAR Array
    By cram in forum C++ Programming
    Replies: 13
    Last Post: 10-13-2004, 07:53 AM
  2. Problem with assigning value to array elements
    By sagitt13 in forum C++ Programming
    Replies: 3
    Last Post: 08-17-2004, 11:26 AM
  3. Merge sort please
    By vasanth in forum C Programming
    Replies: 2
    Last Post: 11-09-2003, 11:09 AM
  4. Need desperate help with two dimensional array problem
    By webvigator2k in forum C++ Programming
    Replies: 4
    Last Post: 05-10-2003, 02:28 PM
  5. From stream/file to a string array problem
    By dradsws in forum C Programming
    Replies: 2
    Last Post: 10-01-2001, 06:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21