Thread: Beginner!!! Please help

  1. #1
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35

    Beginner!!! Please help

    Hi all,

    I am very new to C programming and I need your help.

    Can anyone tell me how can I transmit a frame in C programming?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Transmit to what? What sort of Frame?

    What have you tried so far?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    I have a frame format which is as follows:

    start char 'S'
    device address '0x4E'
    write command '0xFE'
    no of bytes (any no)
    actal bytes
    stop char 'P'.

    How can I combine all this?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, what type of device is this for (Ethernet, Serial, I2C, proprietary, or ...), and what is the hardware (e.g. PC or some specific single-board computer, perhaps?) and software environment (OS, Compiler, libraries, etc) you are using?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    I need to communicate to an I2C using a bridge chip. The controller is XC164CM.

    The bridge chip SC18IM700 is like an interface which helps the host to communicate to an I2C. The format which I have sent before is predefined by the bridge chip.

    I am usiing ASC1 port for communication. The initial structure has been done using DAvE.

  6. #6
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    I am using the XC164CM starter kit by infineon technologies

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Ok, and how far have you got so far?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    The command I have to use to send the 'S' char is ASC1_vSendData ('S');
    I have done that, and it works. I am using a scope meter to check the status on the pins of the hardware. This char is being sent but I am not able to receive it.

  9. #9
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Secondly, its ok if I cant receive it back. I need to send the frame format i posted earlier.

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by reemaambekar View Post
    The command I have to use to send the 'S' char is ASC1_vSendData ('S');
    I have done that, and it works. I am using a scope meter to check the status on the pins of the hardware. This char is being sent but I am not able to receive it.
    So, are you saying that teh I2C bus does not send the character (that is, you do not see it on the scope), or that your receiving side on the SC18IM700 is not receiving it?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Initially, I was just sending a character to check if the bridge chip works. I can confirm that it works. The SC18IM700 communicates with the host using MAX 3227E. For the moment, don't consider the I2C. Now, I know that SC18IM700 is receiving data from ASC1 TX but, ASC1 does not receive the data back from SC18IM700.

    I have pasted the functions below. Can you tell me how can I read the 'S' char using ASC1_uwGetData function?
    Code:
    //****************************************************************************
    // @Function      void ASC1_vSendData(uword uwData) 
    //
    //----------------------------------------------------------------------------
    // @Description   This function writes a send data initialization word into 
    //                the transmit buffer register.
    //                
    //                Note: 
    //                In a multiprocessor system the master with this function 
    //                has the possibility to send data to the selected slave. To 
    //                achieve this, the 9th bit must set on zero.
    //
    //----------------------------------------------------------------------------
    // @Returnvalue   None
    //
    //----------------------------------------------------------------------------
    // @Parameters    uwData: 
    //                Data to be send
    //
    //----------------------------------------------------------------------------
    // @Date          25/11/2008
    //
    //****************************************************************************
    // USER CODE BEGIN (SendData,1)
    void ASC1_send()
    {
    ASC1_vSendData ('S');
    }
    void ASC1_vSendData(uword uwData)
    {
      ASC1_TBIC_IR = 0;        //  reset transmit buffer interrupt request 
      ASC1_TBUF    = uwData;   //  load transmit buffer register
    	while (ASC1_TBIC_IR == 0);//wait till transmission finish
    } //  End of function ASC1_vSendData
    
    
    //****************************************************************************
    // @Function      uword ASC1_uwGetData(void) 
    //
    //----------------------------------------------------------------------------
    // @Description   This function reads out the content of the receive buffer 
    //                register which contains the received data.
    //
    //----------------------------------------------------------------------------
    // @Returnvalue   data that has been received
    //
    //----------------------------------------------------------------------------
    // @Parameters    None
    //
    //----------------------------------------------------------------------------
    // @Date          25/11/2008
    //
    //****************************************************************************
    
    // USER CODE BEGIN (GetData,1)
    
    // USER CODE END
    
    uword ASC1_uwGetData(void)
    {
      return(ASC1_RBUF);     // return receive buffer register
    
    } //  End of function ASC1_uwGetData

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So, can you, using the scope, observe data being sent from the SCM?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    No. I tried using the scope on TX pin of SCM but I am not getting anything back

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by reemaambekar View Post
    No. I tried using the scope on TX pin of SCM but I am not getting anything back
    So do you know if the SCM is actually sending something? Maybe it needs a frame of some sort before sending something back?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    So do you know if the SCM is actually sending something? Maybe it needs a frame of some sort before sending something back?

    --
    Mats
    I guess u r right. Since its a bridge chip, maybe it needs something before sending something. Thats where the frame i mentioned comes in. Its a frame that sends data from host to I2C using the bridge chip. Thats the point where I am stuck up. I logically know what I am supposed to do, but I am not able to write it in C.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Same old beginner question...
    By Sharmz in forum C Programming
    Replies: 15
    Last Post: 08-04-2008, 11:48 AM
  2. What are some good beginner programs I shouold make?
    By oobootsy1 in forum C# Programming
    Replies: 6
    Last Post: 08-09-2005, 02:02 PM
  3. Books, Beginner, MustHave
    By Zeusbwr in forum C++ Programming
    Replies: 9
    Last Post: 10-25-2004, 05:14 PM
  4. Windows programming for beginner (Absolute beginner)
    By WDT in forum Windows Programming
    Replies: 4
    Last Post: 01-06-2004, 11:21 AM