Where should I discuss SD/MMC FAT issues?


Closed Thread
Results 1 to 40 of 93

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Well, I half-ass got the I2C running last night. I knew I'd have to play with the NOP's to get the fastest speeds, but ran out of time. I spent over 2 hours debugging the I2C only to find that I was clocking out using:

    SDA and SCL are port pins

    SDA = 1
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    @ NOP
    SCL = 0
    @ NOP
    etc..

    I spent so much time coding SDA followed by SCL that I guess I couldn't stop! With that fixed I was out of time. I did run the Tcy for MMC to I2C transfers and I'm only saving about 1000 Tcy, far less than what I was hoping for. I know the issue is in the number and placement of @ NOP's. Something is eating tons of time with Tcy up over 54,000, but it's not all going to be in the I2C. The MMC runs without any delays in a serial read, so I'm not sure what's going on.

    Skimask, PM me with an email address and I'll send you a copy of the code. It's just short of 900 text lines and won't fit in a post here. Note that for debug reasons, the I2C reading has been reverted back to the PBP I2CREAD handler.
    Last edited by JD123; - 20th March 2008 at 15:35.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    Skimask, PM me with an email address and I'll send you a copy of the code. It's just short of 900 text lines and won't fit in a post here. Note that for debug reasons, the I2C reading has been reverted back to the PBP I2CREAD handler.
    Just attach it here as a .txt file.

  3. #3
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Okay, I didn't see the attachments in posting.

    Keep in mind that this is still a FORWARD process and I've left a lot of trash in my wake. When it's working the way I want I'll go clean up the trash.

    Also, if it will help stop comments like "well, that was stupid", this is only my 7th PIC program to write, though I bought my first PIC in 1993. No one has ever seen my code before, other than bits and pieces. This kind of feels like getting undressed in public... on stage... at the Opera!

    What I've made:

    An LED blink in asm
    A/D > LCD in asm
    AoA (Angle of Attack) controller for model airplanes in CCS-C
    Automatic slip/skid (yaw) controller for model airplanes in PBP and asm
    A servo driver in PBP and asm
    A proof’er w/LCD for calibrating the servo drivers in PBP and asm
    And now this MMC reader and soon to be data logger in PBP

    This is really only my 4th PBP program, though I have a number of Quick Basic 4.5 PC oriented programs under my belt. Be kind.
    Attached Files Attached Files

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    1st thought right off the bat...
    You're using an '876A. It's easy to replace that with an 18F2620.
    Practically the same pinout, load more code space, lots more ram, more internal functions...
    Having a look at the rest of the code right now...

  5. #5
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    I remember looking at 18F datasheets and felt like I was in a different world. Since the 876 was at hand that seemed the PIC to use for now. The I2C and SPI connections are set on the correct pins and ports, so I can move to those functions later. For now, I just needed to take baby steps in learning how to run the SPI and I2C without adding learning the hardware too. When I (if I) move to those hardware functions I should have a better idea of what they expect and how to use them.

  6. #6
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    I do like one thing about that chip... enough SRAM to load the sectors directly on the PIC.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by JD123 View Post
    I remember looking at 18F datasheets and felt like I was in a different world. Since the 876 was at hand that seemed the PIC to use for now.
    Ah...that's the beauty of it...they're practically identical as far as PBP goes...except for minor changes in registers and such. This type of program should almost port right over, as long as you compare any/all registers you mess with, with the ones on both datasheets to make sure they match well enough.

    If you're looking for all out speed, you might want to take some of your CLOCK_OUT type subroutines (the ones where you only flip a bit back and forth) and put those inline.
    For each Gosub and Return, especially in a PIC16Fxxx, you use at least 2 cycles to GOSUB, 2 cycles to RETURN, and a cycle here and there just to set the page of the bit you want to flip. So that 2 cycle operation, turns into 6 or 8 depending.

    Somewhere up towards the top, you've got a sector loop that runs 0-512 bytes. should be 0-511???

    Figure out which byte variables you use the most (not pins assigned to a variable, but a RAM variable), and assign those to BANK0.
    A variable assigned to BANK0 only needs a single instruction to set the PICs page register to ZERO. A variable assigned to other banks usually needs 2 instructions to set the PICs page register.
    For instance, you've got:
    w_byte var byte
    try:
    w_byte var byte BANK0
    If there is no difference in code space, then you didn't save anything because it was already set in BANK0. If there is a different, then you did save because it was originally in BANK1,2 or 3, depending on total ram usage...

    (I could really go nuts with the colons here! )

  8. #8
    Join Date
    Mar 2008
    Location
    Texas, USA
    Posts
    114


    Did you find this post helpful? Yes | No

    Default

    Somewhere up towards the top, you've got a sector loop that runs 0-512 bytes. should be 0-511???
    That's an error. I'll fix it.

    Figure out which byte variables you use the most (not pins assigned to a variable, but a RAM variable), and assign those to BANK0.
    A variable assigned to BANK0 only needs a single instruction to set the PICs page register to ZERO. A variable assigned to other banks usually needs 2 instructions to set the PICs page register.
    For instance, you've got:
    w_byte var byte
    try:
    w_byte var byte BANK0
    That's good to know - I had no idea. I'll give this a try. Thanks!

    (I could really go nuts with the colons here!)
    You mean in the text format? I've been known to make the text file shorter doing this, but for 'me' it's easier read the logic without hunting down colons.
    Last edited by JD123; - 20th March 2008 at 18:47.

Similar Threads

  1. Reading and Writing from SD/MMC cards as FAT filesystem?
    By charliez in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd June 2006, 22:26

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