Thread: Beginner!!! Please help

  1. #31
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    I would probably write a function that takes the payload and length, along with a buffer (and perhaps buffer-size so you can DETECT that your payload and framing doesn't fit, if the buffer isn't big enough).

    Then just fill in the start of the buffer, use a loop to copy the payload, and then mark the end with a 'P'. Something like this would be the calling code:
    Code:
       char buffer[256];
    
       const char *payload = "abcd";
       BuildFrame(payload, strlen(payload), buffer, sizeof(buffer));
    I'm leaving it to you to define the function itself.

    --
    Mats
    Ok, Thanks.

  2. #32
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Hello again !!!

    Well, as matsp had suggested, I have succeeded in transmitting the frame.

    I need help in something else now.

    I need to configure the General Purpose Input/Output (GPIO) pin of SC18IM700. I need to pull it low.

    How do I define it in C?

    Thanks for your help.
    Last edited by reemaambekar; 12-02-2008 at 05:11 AM.

  3. #33
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    http://www.nxp.com/acrobat/datasheets/SC18IM700_2.pdf

    It seems like writing an 'O' followed by the relevant data for the GPIO port will do the job. Of course, you may have to configure the GPIO port first so that the pin is an output. You need to set PortConf0 or PortConf1 to get that set right.

    --
    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.

  4. #34
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    http://www.nxp.com/acrobat/datasheets/SC18IM700_2.pdf

    It seems like writing an 'O' followed by the relevant data for the GPIO port will do the job. Of course, you may have to configure the GPIO port first so that the pin is an output. You need to set PortConf0 or PortConf1 to get that set right.

    --
    Mats
    Yes, I do know whatever you have mentioned. I need to configure GPIO1 as an output (push pull output config) and then I need to set it to a logic zero.

    I am stuck up at defining PortConf1 and the actual pin. How do I define this in C?

  5. #35
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    You need to set it up according to the table in section 9.2.2, by writitng the corresponding bits in the PortConf1. To do that, you need to use the 'W' command.

    --
    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.

  6. #36
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    You need to set it up according to the table in section 9.2.2, by writitng the corresponding bits in the PortConf1. To do that, you need to use the 'W' command.

    --
    Mats
    Oh! Thanks. When I am using the 'W' command (section 7.1.3), How do I name the inetrnal register? I mean what sort of identification can I give the controller to say that it is PortConf1?(Section 9.1, register summary)

  7. #37
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The description is a big vague, but I expect you send the value 0x02, then the value you want to set the register to, and then a 'P' to end the message.

    --
    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. #38
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    The description is a big vague, but I expect you send the value 0x02, then the value you want to set the register to, and then a 'P' to end the message.

    --
    Mats
    Ya, even I saw the description and I found it a bit vague. I will try doing that.

    Thanks for bearing with me.

  9. #39
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by reemaambekar View Post
    Ya, even I saw the description and I found it a bit vague. I will try doing that.

    Thanks for bearing with me.
    It worked . Thanks .

  10. #40
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by reemaambekar View Post
    It worked . Thanks .
    Hello !!!!

    Well, it doesn't seem to work. Is there any other way if defining the register in C?

  11. #41
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by reemaambekar View Post
    Hello !!!!

    Well, it doesn't seem to work. Is there any other way if defining the register in C?
    Well, in this case, "register" is just a number you send to the other processor, so you can of course use #define, const or enum to declare a constant equivalent of the register number. That will make it more symbolic, but it will not change what is actually sent out from your processor.

    --
    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.

  12. #42
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    Well, in this case, "register" is just a number you send to the other processor, so you can of course use #define, const or enum to declare a constant equivalent of the register number. That will make it more symbolic, but it will not change what is actually sent out from your processor.

    --
    Mats
    Do u mean I could use something like '#define PortConfig1 0x02'?

  13. #43
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by reemaambekar View Post
    Do u mean I could use something like '#define PortConfig1 0x02'?
    Yes. But that will just make it easier to read the code and understand that you are writing to PortConfig1 (which is a good thing). If sending 2 to the device isn't working, then defining PortConfg1 as 2 isn't going to change that.

    --
    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.

  14. #44
    Registered User
    Join Date
    Nov 2008
    Location
    Leicester, UK
    Posts
    35
    Quote Originally Posted by matsp View Post
    Yes. But that will just make it easier to read the code and understand that you are writing to PortConfig1 (which is a good thing). If sending 2 to the device isn't working, then defining PortConfg1 as 2 isn't going to change that.

    --
    Mats
    Ok, thanks. Well I figured out a while before that the function 'ASC1_vSendData()' doesnt send anything other than the ASCII characters. I used the ASC0 port to display contents of the array on the hyperterminal. I sent an array
    Code:
    {'W',0x02,0x08,'P'}
    but it just displays WP.

  15. #45
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by reemaambekar View Post
    Ok, thanks. Well I figured out a while before that the function 'ASC1_vSendData()' doesnt send anything other than the ASCII characters. I used the ASC0 port to display contents of the array on the hyperterminal. I sent an array
    Code:
    {'W',0x02,0x08,'P'}
    but it just displays WP.
    That's probably because 0x02 and 0x08 are "invisible" in hyperterminal.
    --
    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.

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