Send binary file to pic over pc serial port


Closed Thread
Results 1 to 21 of 21

Hybrid View

  1. #1
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Darrel Taylor View Post
    DT>> I've never seen a serial EEPROM with a 256 byte page buffer.
    Can't say that anymore ... 25AA1024

    > So I beleive sending the page to the eeprom takes roughly ~ (1+3+256)*8*100 ns = 208Us

    Even using the MSSP module, you can't do SPI at full 10mhz. But I'm assuming you're using SHIFTOUT, which AT BEST (40mhz OSC) will run at about 500khz clk, which is 2us ea.

    (1+3+256)*8*2us = 4160us

    But don't count on that, because there's additional overhead involved too like retrieving bytes from the array.

    With data as slow as 9600 baud, more than 4 bytes could be received during that time.
    At 38400 baud it would be 16 bytes.
    <br>

    What what what?
    Shiftout??? I'm clocking out the write instruction then the address then the bytes. One bit at every instruction cycle (see 25AA1024 datasheet timing diagrams). One bit per clock cycle that is 10MHz. Maybe I'm not grasping something. Would you check that datasheet?

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    No need to look at that datasheet. It's simple math.

    If you have a PIC with a 40mhz OSC, then the processor is running at FOSC/4, or 10mhz.

    Now let's say you want to make a clk output that's as fast as possible. It will take a minimum of 4 instructions. One to turn the Pin ON, one to turn it off, and a GOTO (2 cycles) to create a loop.

    Those 4 instructions, just cut that 10mhz down to 2.5mhz, and it's only creating a clock signal. Now start counting 8-bit's at a time so you know when to get a new byte, getting the new byte from memory, and rotating it so the bit's can be sent one at a time, and you should see that there's NO way to bit-bang a 10mhz SPI data rate.
    DT

  3. #3
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile Some mystery

    Quote Originally Posted by Darrel Taylor View Post
    No need to look at that datasheet. It's simple math.

    If you have a PIC with a 40mhz OSC, then the processor is running at FOSC/4, or 10mhz.

    Now let's say you want to make a clk output that's as fast as possible. It will take a minimum of 4 instructions. One to turn the Pin ON, one to turn it off, and a GOTO (2 cycles) to create a loop.

    Those 4 instructions, just cut that 10mhz down to 2.5mhz, and it's only creating a clock signal. Now start counting 8-bit's at a time so you know when to get a new byte, getting the new byte from memory, and rotating it so the bit's can be sent one at a time, and you should see that there's NO way to bit-bang a 10mhz SPI data rate.
    Okay, I see but then I don't understand why in the datasheet they show a bit being sent at every rising edge of the clock cycle... What's the explanation for that?

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Sure, from the EEPROM's point of view, it shifts in 1 bit of data for every rising edge of the clock signal. But that clock is derived from the PIC with either software or hardware.

    The EEPROM's(SPI) clock is not the same as the Processors clock.
    <br>
    DT

  5. #5
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile More mystery

    Quote Originally Posted by Darrel Taylor View Post
    Sure, from the EEPROM's point of view, it shifts in 1 bit of data for every rising edge of the clock signal. But that clock is derived from the PIC with either software or hardware.

    The EEPROM's(SPI) clock is not the same as the Processors clock.
    <br>
    You say:
    Now let's say you want to make a clk output that's as fast as possible. It will take a minimum of 4 instructions. One to turn the Pin ON, one to turn it off, and a GOTO (2 cycles) to create a loop."
    -> Well, I also thought that the clock rising and falling was hardware controled (on the SCK pin of the pic), so there is no need to set the pin high then low by software to create a clock. Again, in the datasheet of the pic, at the section dedicated to MSSP, it is told that the clock can be as fast as 10MHz (FOSC/4) = 10Mpbs.

    It seems the more I try to understand the less I do.

    My problem is
    1- to undestand the way things really work
    2- make sure that with a 1ms delay I will have enough to transfer my 256 bytes array into the EEPROM page array if I'm using the HSPLL setting with a 10MHz xtal.
    As with the send file from hyperterminal I have no flow control I unfortunately have a fixed inter-character delay of, let's say, 1ms, this is the time I have to transfer my array of 256 byte to the serial eeprom buffer and then initiate a page write that can take up to 10ms but then I don't care bescause while the 256 next bytes are received by the usart, I can wait for the write to be finished.

    Norm did a project similar to mine (except he is using a 50MHz serial eeprom) and he is using flow control as he wrote a PC program to manage the character output.

    My wish is to be able to transfer an pcm wave file to the eeprom then output is to a 16 bits dac. Timing seems somehow crucial in this project and this I need to understand.

    Is there a way to know exactly how long it takes to transfer my 256 bytes array to the eeprom buffer?

    You say:
    "If you have a PIC with a 40mhz OSC, then the processor is running at FOSC/4, or 10mhz."
    -> Then what is the PLL supposed to do. It should work as a clock multiplier so we get 40MHz out of a 10MHz xtal?
    Last edited by xnihilo; - 15th September 2008 at 11:24.

  6. #6
    xnihilo's Avatar
    xnihilo Guest


    Did you find this post helpful? Yes | No

    Smile Let's see

    High sPC_FLOW_CTS ' Clear PC To Send
    HSerIn 1000,EXIT_HSERIN_MEM_FAIL,[yBYTE_FROM_PC]
    EXIT_HSERIN_MEM_FAIL:
    Low sPC_FLOW_CTS

    How does such code work exactly?
    Does Hserin takes care of reading some control bit (something I would have to do if I were to write a bit-banging routine?), it handshakes with the PC at the rate defined in BAUDCON,RXSTA, TXSTA?
    As I understand it, it will store data from PC in the 8,1 format (so the PC has to also send in this format... will it add the stop bit automaticaly??) when the byte has been received, it is stored in the variable yBYTE_FROM_PC. The 1000ms delay must be a the higher limit of a counter in a loop where Hserin checks periodicaly a flag bit to see if the transfer is complete, right?
    How much time does such code use (if we consider there is no timeout)??

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    > It seems the more I try to understand the less I do.
    And the more I try to explain the less I get across.

    Look, I hate to say it this way but, ...

    I find it hard to believe that someone who doesn't know how the USART works, would understand and be able to use the MSSP module. It's much more difficult. Perhaps you've cut&pasted someone else's code that does use it.

    But I can't seem to get that kind of information out of you.

    Please slow down and look at 1 thing at a time. And in this case, answer 1 question.

    Are you using the MSSP module?
    Keep in mind that there are NO PBP statements that use it.
    You would have to be manually manipulating registers.
    <br>
    DT

Similar Threads

  1. serial to PIC
    By kindows in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 14th July 2009, 13:58
  2. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  3. High Speed Serial Comm PC - PIC and PIC - PIC
    By manumenzella in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 16th January 2007, 21:55
  4. Serial com PIC <> PC - what is best?
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd January 2007, 08:37
  5. Serial communication PIC to PIC help.
    By Rubicon in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th January 2005, 15:45

Members who have read this thread : 0

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

Posting Permissions

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