DS1302 and 18F452


Closed Thread
Results 1 to 3 of 3
  1. #1
    Astro's Avatar
    Astro Guest

    Default DS1302 and 18F452

    I need simple code for DS1302 and 18F452.

  2. #2
    Astro's Avatar
    Astro Guest


    Did you find this post helpful? Yes | No

    Default

    What it is made a mistake ?


    'TESTE
    DEFINE LCD_BITS 8
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 1
    DEFINE LCD_EREG PORTD
    DEFINE LCD_EBIT 3
    DEFINE LCD_RWREG PORTD
    DEFINE LCD_RWBIT 2

    DEFINE LCD_COMMANDUS 10000
    DEFINE LCD_DATAUS 100
    DEFINE LCD_INITMS 1000

    symbol SCL = PORTC.3 ' I2C clock
    symbol SDA = PORTC.5 ' I2C data

    define osc 40

    'INCLUDE "modedefs.bas"
    'include "18f452.inc"

    DEFINE CHAR_PACING 1000
    DEFINE BUTTON_PAUSE 50

    DEFINE I2C_SLOW 1

    'TRISB = %11111111

    S var word 'Segundos
    M var word 'Minutos
    H var word 'Horas
    DD var word 'Dia
    MM var word 'Mês
    AA var word 'Ano
    DIA var word 'Dia da semana

    pause 200
    lcdout $fe,1 'limpa o display
    Pause 500
    lcdout "Aprender"

    Pause 500
    lcdout $fe,1 'limpa o display
    'I2CWRITE SDA,SCL,$84,2,"15"

    loop:

    I2CREAD SDA,SCL,$85,2,[H]
    I2CREAD SDA,SCL,$83,2,[M]
    LCDOUT $FE,1,dec2(H), ":", DEC2(M)

    PAUSE 100

    goto loop

  3. #3
    Join Date
    Sep 2004
    Location
    Mentor, Ohio
    Posts
    352


    Did you find this post helpful? Yes | No

    Smile

    Hi Astro,

    I did a search of this forum using "DS1302" in the search field and found that on March 10, 2006, Travin77 posted code for using the DS1302. You should be able to use the same code just setup the correct config fuses for the 18F452. I recently used code for the DS1337 that was posted back in 2004 I think and used the same program on both a 16F877A and a 18F452. Same program just different configuration setups. They work great on both PICs. The one thing that I didn't do was pay real close attention to the fine print on the data sheets regarding the type of crystal to use. It turns out I had one with too much capacitance and it is making the clock time faster. Changing to the correct crystal and now everything is okay.

    Try it out!

    BobK

Members who have read this thread : 2

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