Counting led blinks..


Closed Thread
Results 1 to 40 of 93

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, in the PIC pins and registers for SD/MMC card
    Code:
    SD_WE        Var    PORTA.4    ' SD card write protect
    SD_WE_TRIS    Var    TRISA.4    ' SD card write protect direction
    SDI        Var    PORTB.0    ' SPI data in
    SDI_TRIS    Var    TRISB.0    ' SPI data in direction
    SCL        Var    PORTB.1    ' SPI clock
    SCL_TRIS    Var    TRISB.1    ' SPI clock direction
    SD_CS        Var    PORTB.3    ' SD card chip select
    SD_CS_TRIS    Var    TRISB.3    ' SD card chip select direction
    SD_CD        Var    PORTB.4    ' SD card detect
    SD_CD_TRIS    Var    TRISB.4    ' SD card detect direction
    SDO        Var    PORTC.7    ' SPI data out
    SDO_TRIS    Var    TRISC.7    ' SPI data out direction
    PortB.0. PortB.1,PortB.3 and PortB.4 is already in use by a keypad, can I move it to PortD instead?
    Like this...
    Code:
    SD_WE        Var    PORTA.4    ' SD card write protect
    SD_WE_TRIS    Var    TRISA.4    ' SD card write protect direction
    SDI        Var    PORTD.0    ' SPI data in
    SDI_TRIS    Var    TRISD.0    ' SPI data in direction
    SCL        Var    PORTD.1    ' SPI clock
    SCL_TRIS    Var    TRISD.1    ' SPI clock direction
    SD_CS        Var    PORTD.3    ' SD card chip select
    SD_CS_TRIS    Var    TRISD.3    ' SD card chip select direction
    SD_CD        Var    PORTD.4    ' SD card detect
    SD_CD_TRIS    Var    TRISD.4    ' SD card detect direction
    SDO        Var    PORTC.7    ' SPI data out
    SDO_TRIS    Var    TRISC.7    ' SPI data out direction
    Regards,
    tacbanon

  2. #2
    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..

    That should not be a problem.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: Counting led blinks..

    Hi, before I change to my desired pins, I made a test(using the original code)...but gives me this "Init: 6 1 255". I don't understand the code I used for testing works before.
    Do you know what's causing it?

    regards,
    tacbanon

  4. #4
    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.

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

  6. #6
    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

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

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