Counting led blinks..


Closed Thread
Results 1 to 40 of 93

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Open the SDFS file and look at the CE_xxx .
    Your card did not initialize. Could be lots of things from a loose wire to a bad card. Bad as in file format corrupt to just wore out.
    If the connections are good see if the card can be read in a PC, check the format.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Oh my, I think I broke my sdcard module. I double checked the wires I'm using and I reconnect and disconnect them to the devboard more than 10 times still the same result. The SDCard is okay (its in FAT format). I remembered I connect it to PortB earlier the same port where the keypad is also connected. this could have ruin the module...

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    For the mean time while I'm waiting for my new sdcard module(will come within a week). I will try to study on eeprom(Pic18F4550's internal). Thank you again to this wonderful forum(people) and to macrackit for the precious time... until nextime.

    regards,
    tacbanon

  4. #4
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, I've been playing some time with READ and Write command on the internal eeprom, I'm having trouble updating DATA @6,5,"54321". Probably I'm doing it the hard way. Can you help me out what I'm doing wrong?
    Code:
    'My Tested Prototype with Pic18F4550 and EEPROMInclude "modedefs.bas"
    INCLUDE "C:\PBP\USB18\EE_Vars.pbp"           ; Include the EE_var routines
    asm
        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
    endasm
    DEFINE    OSC 48
    ADCON1 = 15               ' Set all I/Os to Digital      
    CMCON = 7                 ' Disable Comparators
    INTCON2.7 = 0
    'EEprom data
    'U1    VAR WORD  :  @  EE_var  _U1, WORD, 9999 ' for later use
     
    DATA @0,5,"12345"
    DATA @6,5,"54321"
    DATA @13,5,"14332"
    DATA @19,5,"24432"
    DATA @25,5,"85921"
    
    
    TRISA = %00000000
    TRISD = %00000000
    PORTD = %00000000
    TRISB = %11110000    ' Set Keypad I/O 
    PORTB = 0             ' Set columns LOW  
    PortA = 0
    
    
    myvarkey    var byte
    ByteA        var Byte[6]  
    B0          var byte[5]
    cnt         var byte
    x           var byte
    cnt = 0
    asciichar var byte
    address var byte
        '    ---------------------------------[Program Start]----------------------------------------------
    serout2 PortD.5,T9600,[$1B,$63,$30]  
    pause 200
    serout2 PortD.5,84,[$1B,$45,"EEPROM"]
    serout2 PortD.5,84,[$D,"Studies"]
    serout2 PortD.5,84,[$1B,$63,$30]
    pause 2000
    Serout2 PortD.5,84, [$1B,$45]
    main:
    
    
    @ READKEYPAD _myvarkey
    lookup myvarkey,[0,"123A456B789C*0#D"],Key 
    Serout2 PortD.5,84, [$1B,$45,"Key = ",Key]
     
    if Key = "#"  and cnt < 6 then
         if ByteA[0]="1" and ByteA[1]="9" then   ' wait 19 is pressed before updating 
            Serout2 PortD.5,84, [$D, "Special Key"]        
            pause 20
            serout2 PortD.5,84,[$D,str ByteA\cnt]
            READ 6,x
             for address=6 to x+6
                Write address+1, ByteA[address]
             next address
            cnt=0   
         endif  
         
    else                         
         ByteA[cnt]=Key
         Serout2 PortD.5,84, [$D, ">" , ByteA[cnt]]
         cnt=cnt+1
    
    
    Endif
    
    
    if cnt > 5 then
    Serout2 PortD.5,84, [$D, "5Digits only"]
    cnt = 0
    ENdif
    
    
    
    
    if Key = "A" then
    READ 0,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0 to x
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    
    
    if Key = "B" then
    READ 6,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0+6 to x+6
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    
    
    if Key = "C" then
    READ 13,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0+13 to x+13
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    
    
    if Key = "D" then
    READ 19,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0+19 to x +19
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    
    
    if Key = "*" then
    READ 25,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0+25 to x +25
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    pause 500
    goto main
    But updating Data @0 ,"12345" was not a problem, I'm stuck passed @0 location.

    regards,
    tacbanon

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    This:
    Code:
    DATA @0,"12345"
    DATA @6,"54321"
    produces this when the EEPROM is read back
    31 32 33 34 35 00 35 34 33 32 31 00 FF FF

    Is that what you want?

    Did you find out what went bad with the SD card module? You can always use the SD card socket without all the other stuff on the module, it is easy if the MCU is running ~3 volts.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Code:
    DATA @0,"12345"
    DATA @6,"54321"
    Sorry If I was not being clear... how can I rewrite them and read back as in the format of "56988" or "65431".
    Before overwriting DATA @6,"54321" I can read back as "54321". But after updating it gives me like Hex numbers.

    I don't know exactly what happened to sdcard it just dont work as before. But I will try to test it again later.

    thanks,
    tacbanon

  7. #7
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi mackrackit, sorry if was not making clear. I want to read back from eeprom in the format of example "12345" or "65432" and I can do this uisng the following code.
    Code:
    if Key = "A" then
    READ 0,x
    serout2 PortD.5,84,[$D,Dec x," "]
    pause 1000
    for address=0 to x
        READ address,asciichar
        serout2 PortD.5,84,[$D,asciichar]
    next address
    pause 1000
    cnt = 0
    endif
    And I noticed that if I rewrite the value of DATA @6,5,"54321" by entering "19325" and read it back I get "QZu" not "19325"..how do I resolve this?
    I will try to test the sdcard tonight, hope something comes up....

    thanks,
    tacbanon
    Last edited by tacbanon; - 2nd November 2011 at 12:59.

  8. #8
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi I finally got my eeporm problem solved..I figured that it needs 2 location space in between.
    Code:
    DATA @0,5,"12345"
    DATA @7,5,"54321"
    DATA @14,5,"14332"
    DATA @21,5,"24432"
    DATA @28,5,"85921"
    works great...
    BTW just want to ask if there is a possible to press a key that consist of several characters, for example if I pressed key 1 in successive I can get a character 'a','b','c'. similar to a cellphone keypad.

    regards,
    tacbanon
    Last edited by tacbanon; - 2nd November 2011 at 15:01.

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