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

    Well, I am not sure why your code is not working on PORTC.3 and PORTC.4. I just tried it here and it is running. The code I used is below.

    Port A. Did you turn the analog off? ADC

    You have to use an 18Fxx with SDFS as LONG variables are needed.

    Code:
    ' 16F877A RTC
    ' 10/30/2011
    DEFINE OSC 4
    #CONFIG
        __config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF
    #ENDCONFIG
    
    
    LED     VAR PORTB.5
    TX      VAR PORTD.1  ' DATA SEND PIN
    BAUD    CON 18030	' 18030 = 600 BAUD
    
    
    'RTC pins on 877a
    SDA	Var	PORTC.4
    SCL	Var	PORTC.3
    
    
    ' Allocate variables
    RTCYear	Var	Byte
    RTCMonth Var Byte
    RTCDate	Var	Byte
    RTCDay	Var	Byte
    RTCHour	Var	Byte
    RTCMin	Var	Byte
    RTCSec	Var	Byte
    RTCCtrl Var	Byte
    
    
    TRISC= %11111111
    CMCON = %00000111                   
    
    
    ' Set initial time 
    	RTCYear = $10
    	RTCMonth = $03
    	RTCDate = $23
    	RTCDay = $02
    	RTCHour = $19
    	RTCMin = $35
    	RTCSec = 0
    	RTCCtrl = 0
    	
    'Gosub set		' Set the time
    
    
    Goto mainloop		' Skip over subroutines
    
    
    ' Subroutine to write time to RTC
    set:
    	I2CWrite SDA,SCL,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCYear,RTCCtrl]
    	Return
    
    
    ' Subroutine to read time from RTC
    gettime:
    	I2CRead SDA,SCL,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCDay,RTCDate,RTCMonth,RTCYear,RTCCtrl]
    	Return
    
    
    mainloop:
    	Gosub gettime		' Read the time from the RTC
        TOGGLE LED
        SEROUT2 TX, BAUD,["Date:",  hex2 RTCDate, "/",hex2 RTCMonth, "/" , hex2 RTCYear,13]
        SEROUT2 TX, BAUD,["Time:", hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec,13]
    
    
    '    Lcdout $fe, 128,"Date:",  hex2 RTCDate, "/",hex2 RTCMonth, "/" , hex2 RTCYear
    '	Lcdout $fe, $c0, "Time:", hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec
    
    
    	Pause 500
    	GOTO mainloop
    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..

    okay I think I know whats the problem, I found out that one my file I'm working has this code ADCON1 = %00001111 ' A/D converter off...which is different from the file I post. So this means I have to work on 18F.

    thanks again,
    tacbanon

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

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

    That should not be a problem.
    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..

    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

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

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

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