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

    Dear Charlie,

    I am new in picbasicpro. Where can i find a sample SPI coding to be referred? Currently Im using TRH031M as "slave" in SPI mode and pic16f877 as a MCU (master in SPI mode)

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

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

    Hi,
    Start by taking a look in the PBP3 installation folder. There's sub-folder called EXAMPLES\GENERAL PBP.
    The file shift.pbp demonstrates how to use the SHIFTIN/SHIFTOUT commands and the files spimast.pbp and spislave.pbp demonstrates how to use the SSP/MSSP module in the PIC to do SPI at the hardware level.

    The PBP manual covers the use of SHIFTIN/SHIFTOUT and there should be plenty of example code around the forum. Probably not exactly the code you need but plenty to get ideas from. If you get stuck post specific questions and you'll most likely get plenty of help.

    With that said, if you're new to PBP then perhaps getting up to speed by interfacing a simple shiftregister or something as a start might be a good idea.

    /Henrik.

  3. #3
    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 Henrik,

    As per my understanding, to perform SPI between a master and a slave, 2 programmable PICs are needed (1 for master& 1 for slave) while TRH031M I am using is kinda transmitter which cannot be programmed. So, can I send only data from my PIC16f877(master) to TRH031M without programming TRH031M? Kindly advice!

    Thanks.
    Last edited by Hanson; - 15th April 2014 at 09:28.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

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

    Hi,
    With SPI there's always one master and one or more slaves. The master is always responsible for generating the clock. In your case the PIC would be the master and the TRH031M would be the slave. Master/slave has nothing to do with the direction of the data, it can go from master to slave, from slave to master or both ways.

    So, yes, of course you can send and receive data to/from the TRH031M without reprogramming it - it's already "programmed" to act as a slave.

    /Henrik.

  5. #5
    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 Henrik,

    Thank you so much for the clarification made. Considering "slave(trh031m)" already received data from "master(16f877)" and I wish to send received data through TX1 of TRH031M, still I need to program one PIC to perform this task, isn't it?

    Regards

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

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

    Hi,
    Yes, of course, you need to program the PIC to send and receive commands and data to/from the TRH031M according to the datasheet.

    /Henrik.

  7. #7
    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 Henrik,

    Let's say Im now sending a serial data "Hanson" and i set my start frame as "AAAAA" and end frame as "EEEEE". So the serial data Im sending is like:
    "AAAAAHANSONEEEEE"

    at sending side:

    start:
    SEROUT dataout,N300,["AAAAA","HANSON", "EEEEE"]
    pause 100
    goto start

    My problem is at the receiving side, I wish to filter my received data before storing them. The only solution I have thought was "nested IF loop" but microcode studio don't support this kinda command rather just "IF...THEN". Right?
    so, how can I write my coding to perform this data filtering task?
    eg:
    check if data_in[0]="A" ;if yes then proceed checking for second "A"
    check if data_in[1]="A" ;if yes then proceed checking for third "A"
    check if data_in[2]="A" ;if yes then proceed checking for forth and fifth "A"
    check if data_in[13]="E" ;if yes then check for second "E"
    .
    .
    .
    check if data_in[16]="E" ;if all conditions matched (receive first 5 "A" and last 5 "E" properly) then store data_in
    else loop back subroutine and repeat checking for first "A"

    Regards

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, 21:05
  2. Ir problem sending data
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 6th December 2009, 05:27
  3. 16F676 programming problem
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 18th May 2009, 17:39
  4. VB sending serial data to PIC
    By Tissy in forum Serial
    Replies: 7
    Last Post: - 8th March 2006, 18:31
  5. Sending data over USB via VB
    By Tissy in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 12th September 2005, 01: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