This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

settng up rs232 variable

Hi, can anyone tell me how i would set up a variable that expects a certain amount of data to be received through rs232.

i.e. to receive 18 bytes of data only once the the rx pin has been set to input.

thanks guys

Parents Reply Children
  • so, are you saying that all your unit has to do is to receive characters/bytes and resend them?

    what is the baudrate in and out?

    Erik

  • Yes that is basically all i hacve to do, although i will need to write the bytes to eeprom for storage as a backup if the sending fails which if it does then they can be resent. the baud rate is 9600.

  • you have all the processing time you need to run this simple task at 9600, so
    1) write the code
    2) debug it
    3) smile

    I would totally forget all about using library functions, let the sensor write to a circular buffer, upon receiving characters wait for previous byte tranamit complete (TI should be almost immediate) and transmit the char. Let main take care of storing from the circular buffer to the EEPROM.

    NOTE: if you bit-bang the EEPROM you WILL "have a lot of fun" doing this, select a derivative that can drive the EEPRROM (IIC, SPI or whatever) through hardware.

    Erik

  • Hi well this is the code i have atm for the transmitter:

    void TRANSMITTER(void)
    {
    
    
        unsigned char Mode;
            unsigned char b;
            unsigned char Packet;
            unsigned int address;
    
            if (Mode == 'd')
            {
                Packet = GetChar();
                    Configuration();
                    DELAY_100us(200);
                            for(b=0;b<txconf.n;b++)
                                            {
                                            SPI_ReadWrite(txconf.buf[b]);
                                            }
                                                    Standby();
                                                    DELAY_100us(200);
                                    for (address=0x00;address<0xff;address++)
                                {
                            EEWrite(address,Packet);
                            }
                                                    for (Packet=0;Packet<18;Packet++)
                                                    {
                                                    TRANSMIT_Packet(Packet);
                                                    }
    
            }
    
    }
    
    


    if (Mode == 'd') is just for the pulse pin i have set up to ensure the data to be received is data and not a command
    as can be seen i have set up an unsigned char Packet and i am using Packet = GetChar(); to retreive the byte.....if i remove the GetChar() how can i assign the byte received to Packet to ensure that byte is sent, further down the code?

    Cheers Rhys

  • can someone please analyse this code? thanks

  • can someone please analyse this code

    HOW?

    what does packet() do ?
    what does configuration() do: ?
    why do you indent 'a mile' use spaces, not table?

    Erik

    PS: you have two options a) wait till it may be convenient for a responder if you want it for free OR b) pay for it.

    Do you really think there are people sitting around just waiting to solce your problem for free?

  • Are you and martyn kay working on the same project or are you the same person?

    http://www.keil.com/forum/docs/thread9637.asp

  • "can someone please analyse this code?"

    For a start, you need to fix the layout (indentation) - it's all over the place!

    Use spaces - do not use TABs.

    You know where you are with spaces, but the interpretation of TABs is entirely at the whim of the displaying application and/or device and its/their particular configuration(s)!

    And use the 'Preview' before posting to verify that it's OK.

  • Well as you seem to respond to most posts i am presuming you are forum moderators employed by keil?? if not then i am truly greatful for your help. the configuration() etc just set up the nrf24e1 CS and CE, and in response to Dan, we are not the same person but are working on the same project......im not that immature.