Serial data sending#do someone came across programming 16f676 with TRH031M?


Closed Thread
Results 1 to 17 of 17

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Serial data sending#do someone came across programming 16f676 with TRH031M?

    Hi,
    I don't know if it's you or me who are the most confused right now.....
    You seem to be mixing SHIFTIN/SHIFTOUT with the use of the MSSP module, use either or. And, previously you said you used SEROUT on another PIC to send data, then you can't use SHFTIN to receive it - if that's what you're trying to do. And, no, you can't use any of the methods to shift data into the SDO pin since that is the data output pin.
    Code:
    ActualData var word[8]
    j var byte[8]
    B0 var byte
    Any reason for ActualData to be WORDS?

    Code:
    send1:
    SHIFTIN SDI, SCK, MSBPRE, [ActualData\8]
    j=ActualData
    SHIFTOUT SDO, SCK, MSBFIRST, [j]
    Not sure what the purpose of this is but there's no reason to assign the value of ActualData to J and then send J out using SHIFTOUT, you could just as well shift out ActualData directly (instead of a copy of it).

    Code:
    For j = 0 to 7 ' loop for 8 characters
    SSPBUF = 0 ' write to SSPBUF to start clock
    GoSub letclear ' wait for receipt
    B0[j] = SSPBUF ' store received character in array
    Next j ' get next character
    Return
    Here you're treating B0 as an array when it's decalred as a BYTE. This is a critical error as it will write to memory location "beyond" B0 and corrupt what ever is there. PBP does not do any boundry checks on arrays so you need to be careful.

    This post probably isn't of much help to you but I've quite honestly lost track of what exactly you're trying to do. Now, we've got SERIN, SHIFTIN/SHIFTOUT and the use of the MSSP module in the mix - all at once and I'm struggeling to keep up. Again, I suggest that you get used to various ways of doing SPI by interfacing something simpler than the TRH031M - which, by the way, I've never used so I don't know how it works. But I looked, briefly, at the datasheet and nowhere can I find that you're supposed to send "?" to start a "conversion" - I thought the chip was for RFID communications, not a converter....

    /Henrik.

  2. #2
    Join Date
    Apr 2014
    Posts
    9


    Did you find this post helpful? Yes | No

    Default Re: Serial data sending#do someone came across programming 16f676 with TRH031M?

    Hi,

    Sorry Henrik for making you confused. I am not sure that I can use SERIN with SHIFTIN/OUT so I mistakenly mixed them up.

    Actually what Im doing is transmit a data at 13.56MHz by using TRH031M and the data is from pic16f877. Since trh031m has 4 type of modes, SPI,parallel etc, i configured my hardware to perform SPI mode. So Im trying to use "master slave" communication to send my data from PIC to trh031m as trh031m already pre-configured as a "slave" by default which u told me in the previous comment.

    Can you kindly teach me what is the correct way to send my received data from PIC to trh031m? Do "master slave" communication work in performing my task?

    appreciate your kind helps.

    Regard.

  3. #3
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: Serial data sending#do someone came across programming 16f676 with TRH031M?

    Hi,
    All I can say is that the PIC and PBP supports SPI communcation, either by using SHIFTIN/SHIFTOUT or using the MSSP peripheral module built into most devices. That gives you the interface between the PIC (master in this case) and the TRH031M (slave in this case). I see no reason for it not to work, however there are occasions where SHIFTIN/SHIFTOUT is NOT an option because the the slave devices is shifitng in and out data at the same time, in those cases you must use the MSSP module because the SHIFTIN/SHIFTOUT either shift data in OR shifts data out they can't do both simultanously.

    But, the TRH031M is a complicated device, it's not as simple as just "send some data" to it. It needs setting up, it needs commands sent to it, it needs data sent to it, it needs new commands sent to it, it needs to be polled for status and so on. You absolutely must read and understand the datasheet or you won't be able to make this work. Again, I've never used the device so *I* don't know how it works, I've just very briefly browsed thru the datasheet.

    I strongly suggest you put your PIC, a 74*595 (serial in, parallel out) and a 74*165 (parallel in, serial out) shiftregisters, a couple of LEDs and a couple of switches on a breadboard and get used to communicating with those. Use SHIFTOUT to write data to the 74*595 and SHIFTIN to read data from the 74*165. When you have that working and understand how it works, try the MSSP module instead of SHIFTIN/SHIFTOUT. With that you'll be able to write one byte to the 74*595 and read one byte from the 74*165 all in one go - which MIGHT be what's needed for the TRH031M - I'm not sure.

    THEN get back to the TRH031M.

    /Henrik.

Similar Threads

  1. Problem on sending data on serial port
    By bwaxing in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 3rd May 2011, 22:05
  2. Ir problem sending data
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th December 2009, 06:27
  3. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 18:39
  4. VB sending serial data to PIC
    By Tissy in forum Serial
    Replies: 7
    Last Post: - 8th March 2006, 19:31
  5. Sending data over USB via VB
    By Tissy in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 12th September 2005, 02:00

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts