help with pic16f887


Results 1 to 40 of 61

Threaded View

  1. #32
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Ok I am backing up a bit now, I am trying to make things work seperatly ( just your post mackackit)
    First: I can make the DS1337 work ONLY with SDA and CLK port of the pichip 16F887 (40 pins). I tried using D.0 and D.3 which are digital ports but nothing.
    Here is the code for that. other ports did not work:
    Code:
    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8
    ANSELH = 0
    
    
    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////
    
    DEFINE LCD_DREG PORTB 	' Set LCD Data port
    DEFINE LCD_DBIT 4 		' Set starting Data bit (0 or 4) if 4-bit bus  RB.4, RB.5, RB.6, RB.7
    DEFINE LCD_RSREG PORTB 	' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 		' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB	' Set LCD Enable port
    DEFINE LCD_EBIT 0 		' Set LCD Enable bit
    DEFINE LCD_BITS 4 		' Set LCD bus size (4 or 8 bits) '4 therefore put wire at 4, 5, 6 and 7 of LCD
    DEFINE LCD_LINES 2 		' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000
    
    
    SDA var PORTC.4                     ' RTC data 
    SCL var PORTC.3                     ' RTC clock
    RTCSec var byte :RTCMin var byte :RTCHour var byte :RTCWDay var byte :RTCDay var byte 
    
    
    TRISB= %11111111
    TRISC= %00000000
    TRISD= %11000000 
    
    pause 1000
    I2CWRITE SDA,SCL,$D0,$00,[$08,$03,$08,$7,$07,$2,$10,$80] ' Write to DS1307
    
    	     pause 50
    		
    read_ds:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
    			I2CRead SDA,SCL,$D1,$00,[RTCSec,RTCMin,RTCHour,RTCDay]
    			lcdout $FE,1, "  Time ", dec 1
    			lcdout $FE,$C0, "Day:",dec RTCDay,"  ", dec RTCHour,":", dec RTCMin,":", dec RTCSec
     pause 100
    goto read_ds
    end

    Second:
    I cannot store or read anything from the 24LC1025 EEPROM chip.. Here si the code for that:
    Code:
    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8
    ANSELH = 0
    
    
    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////
    
    DEFINE LCD_DREG PORTB 	' Set LCD Data port
    DEFINE LCD_DBIT 4 		' Set starting Data bit (0 or 4) if 4-bit bus  RB.4, RB.5, RB.6, RB.7
    DEFINE LCD_RSREG PORTB 	' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 		' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB	' Set LCD Enable port
    DEFINE LCD_EBIT 0 		' Set LCD Enable bit
    DEFINE LCD_BITS 4 		' Set LCD bus size (4 or 8 bits) '4 therefore put wire at 4, 5, 6 and 7 of LCD
    DEFINE LCD_LINES 2 		' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000
    
    
    SDA var PORTC.4                     ' RTC data 
    SCL var PORTC.3                     ' RTC clock
    RTCSec var byte :RTCMin var byte :RTCHour var byte :RTCWDay var byte :RTCDay var byte 
    
    
    TRISB= %11111111
    TRISC= %00000000
    TRISD= %11000000 
    
    pause 1000
    I2CWRITE SDA,SCL,$A0,$00,[$08,$03,$08,$7,$07,$2,$10,$80] ' Write to eeprom
    
    	     pause 50
    		
    read_eeprom:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
    			I2CRead SDA,SCL,$A1,$00,[RTCSec,RTCMin,RTCHour,RTCDay]
    			lcdout $FE,1, "  Time ", dec 1
    			lcdout $FE,$C0, "Day:",dec RTCDay,"  ", dec RTCHour,":", dec RTCMin,":", dec RTCSec
     pause 100
    goto read_eeprom
    end
    Last edited by lerameur; - 5th December 2010 at 19:22.

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