Menu

Does 16F1847 work with GCGB?

Help
2011-09-29
2013-05-30
  • Nobody/Anonymous

    Hi.
    I am using 16F648/16F88 to control my gas boiler (it is my first aplication with pics). But now I have a problem, I am using interrupt (time) and my code will be greater than xKb (page boundary or so?) When I add new features and reprogram, PIC doesnt work if interrupt - timer0 is enabled.
    So I want to use new pic 16F1847 with more memory but can I use this PIC with GCGB?
    I have PCB for this type of PIC so I want to make it with 16f..
    Does PIC18F same problem with program memory?
    Thanks for answer

     
  • Vaclav

    Vaclav - 2011-09-30

    this is my code

    ;Chip Settings
    #chip 16F648A,4,194304
    #config BOREN=ON, CP=OFF, DATA=CP_OFF, PWRTE=ON, WDT=OFF, MCLRE=OFF, OSC=HS

    ;Defines (Constants)
    #define LCD_IO 4
    #define LCD_NO_RW
    #define LCD_Enable PORTA.2
    #define LCD_RS PORTA.4
    #define LCD_DB4 PORTB.4
    #define LCD_DB5 PORTB.5
    #define LCD_DB6 PORTB.6
    #define LCD_DB7 PORTB.7
    #define Tlacitko0 PORTB.0
    #define Rele PORTB.1
    #define Plamen PORTB.2
    #define Kotel PORTB.3

    ;Variables
    Dim casT As word ; cas ve vterinach pri topeni time in seconds for heaters/radiators
    Dim casV As word ; cas ve vterinach pri ohrevu vody time in seconds for hot water heating
    Dim cyklusTD As byte ; pocet cyklu za den loops per day for heaters
    Dim cyklusVD As byte ; pocet cyklu za den loops per day for hot water heating
    Dim plamenTS As byte ; celkovy cas plamene topeni total time for heaters in last loop
    Dim plamenTM As byte ;
    Dim plamenTH As byte ;
    Dim plamenVS As byte ; celkovy cas plamene ohrevu vody total time for hot water heating in last loop
    Dim plamenVM As byte ;
    Dim plamenVH As byte ;
    Dim sekundyT As byte ; cas horeni plamene v rezimu topeni total time for heaters from switch-on
    Dim minutyT As byte ;
    Dim hodinyT As byte ;
    Dim sekundyV As byte ; cas horeni plamene v rezimu vody total time for hot water from switch-on
    Dim minutyV As byte ;
    Dim hodinyV As byte ;
    Dim t1 As word ; pocet preteceni timeru1 count timer1 overflow
    Dim t2 As byte ; pocita vteriny, nuluje se count seconds
    Dim tT As word ; aktualni cas horeni topeni live time countig for heaters
    Dim tV As word ; aktualni cas ohrevu vody live time countig for hot water
    Dim romC As byte ; pozice v eeprom pro cteni position in EEPROM for read
    Dim romZ As byte ; pozice v eeprom pro zapis position in EEPROM for write
    Dim romCP As byte ; pouzit pro cislo cyklu used for loops number
    Dim romCS As byte ; vyhleda prazdnou bunku a od ni zacne zapisovat find free eeprom cell
    Dim rom As byte ; velikost vyuziti eeprom (pro 256 - word)
    Dim secH As byte ;
    Dim minH As byte ; cas hodin, pokud budou brany z timeru1 time from timer1
    Dim hodH As byte ;
    Dim hod As word ;
    Dim kontakt As word ; odpojeni termostatu na urcitou dobu disconnect room thermostat for PRODLEVA
    Dim prodleva As word ; cas odpojeni termostatu delay for KONTAKT
    Dim stavK As byte ; stavk kotle, 0 - klid, 1 - topení, 2 - voda as byte boiler status - 0 - inaction, 1 - heaters, 2 - hot water
    Dim termostat As bit ; 0 - sepnut, 1 - rozpojen (bit - zlobi) thermostat status 1 - disconnected by KONTAKT/PRODLEVA
    Dim tl0 As byte ; pro praci s tlacitkem na portb.0 button on portb.0
    Dim stavT As byte ; vykreslování posledních cyklů topení write on LCD times for heater's loops
    Dim t5 As byte

    ;Interrupt Handlers
    On Interrupt Timer1Overflow Call T1O
    On Interrupt ExtInt0 Call Tlacitko

    Dir Kotel In
    Dir Plamen In
    Dir Rele Out
    Dir Tlacitko0 In
    casT = 0
    casV = 0
    cyklusTD = 0
    cyklusVD = 0
    plamenTS = 0
    plamenTM = 0
    plamenTH = 0
    plamenVS = 0
    plamenVM = 0
    plamenVH = 0
    sekundyT = 0
    minutyT = 0
    hodinyT = 0
    sekundyV = 0
    minutyV = 0
    hodinyV = 0
    t1 = 0
    t2 = 0
    tT = 0
    tV = 0
    romC = 0
    romZ = 0
    romCP = 2
    romCS = 0
    rom = 255
    tl0 = 0
    secH = 0
    minH = 0
    hodH = 0
    hod = 0
    kontakt = 0
    prodleva = 0
    stavK = 0
    termostat = 0
    wait 2 s
    Set Rele On
    InitTimer1 Osc, PS1_1/8
    StartTimer 1
    startprog
    If t2 > 2 Then
    t2 = 0
    End If
    stavT = 0
    Set Rele Off
    Locate 0, 0
    Print "00T"
    Locate 1, 0
    Print "00V"
    LCDcasT
    LCDprotopenoT
    LCDcasV
    LCDprotopenoV
    LCDhodinky

    'StartProg2
    'StartEEPROM
    Set Rele Off
    Start:
    If Kotel = 0 AND Plamen = 0 Then
    stavK = 1
    casT = tT
    DobacykluT
    LCDcasT
    End If
    If Kotel = 1 AND Plamen = 0 Then
    stavK = 2
    casV = tV
    DobacykluV
    LCDcasV
    End If
    If Plamen = 1 Then
    If stavK = 1 Then
    cyklusTD = cyklusTD + 1
    LCDcyklusT
    PlamenDenT
    LCDcasT
    LCDprotopenoT
    ZapisROM
    tT = 0
    stavK = 0
    kontakt = 0
    termostat = 1
    prodleva = 900
    If minutyT = 0 Then
    prodleva = 1200
    End If
    If hodH < 8 Or hodH > 20 Then
    prodleva = prodleva * 2
    End If
    Set Rele On
    End If
    If stavK = 2 Then
    cyklusVD = cyklusVD + 1
    LCDcyklusV
    PlamenDenV
    LCDcasV
    LCDprotopenoV
    tV = 0
    stavK = 0
    End If
    End If
    If t2 = 2 Then
    hod = hod + 1
    If hod = 60 Then
    minH = minH + 1
    If minH = 60 Then
    minH = 0
    hodH = hodH + 1
    End If
    If hodH = 24 Then
    hodH = 0
    End If
    hod = 0
    End If
    If Kotel = 1 AND Plamen = 0 Then
    stavK = 2
    tV = tV + 1
    DobacykluV
    End If
    If Kotel = 0 AND Plamen = 0 Then
    stavK = 1
    tT = tT + 1
    End If
    If termostat = 1 Then
    Odpojeni
    End If
    t2 = 0
    Test
    End If
    If stavT <> 0 Then
    If stavT = 1 Then
    TlacitkoLCD
    End If
    If stavT = 2 Then
    TlacitkoLCD2
    End If
    stavT = 0
    End If
    If hod = 0 Then
    LCDhodinky
    End If
    Locate 0,8
    If Rele On then
    Print "#"
    end if
    If Rele Off then
    Print " "
    end if
    Goto Start

    'T1O pocita cas a jine
    'LCDcyklusT/V zobrazi pocet cyklu
    'LCDcasT/V zobrazi cas horeni plamene topeni/ohrevu vody
    'DobacykluT/V pocita cas horeni plamene cyklu
    'PlamendenT/V pocita cas horeni plamene celkem/za obdobi
    'Tlacitko0 e procesy po stisknuti tlacitka na portu B0
    'Hodinky pocita realny cas
    'Odpojeni rozpoji obvod termostatu
    'ZapisROM zapise dobu cyklu topeni do EEPROM

    Sub T1O
    t2 = t2 + 1
    t5 = t5 - 1
    End Sub

    Sub Test
    If Tlacitko0 = 1 Then
    If tl0 < 10 Then
    tl0 = tl0 + 1
    If tl0 = 10 Then
    stavT = 2
    End If
    End If
    End If
    End Sub

    Sub Tlacitko
    If Tlacitko0 = 0 Then
    stavT = 1
    End If
    End Sub

    Sub TlacitkoLCD
    tl0 = 0
    EPRead romC, TempM
    EPRead romC + 1, TempS
    Locate 0, 8
    If romCP/2 < 10 Then
    Print "0"
    End If
    Print romCP/2
    Print " "
    If TempM AND TempS = 255 Then
    Print "-:-"
    End If
    If TempM <> 255 Then
    If TempM <10 then
    Print "0"
    End If
    Print TempM
    Print ":"
    If TempS < 10 then
    Print "0"
    End If
    Print TempS
    End If
    romCP = romCP + 2
    romC= romC - 2
    End Sub

    Sub TlacitkoLCD2
    Locate 0,8
    LCDprotopenoT
    tl0 = 0
    romC = romZ - 2
    romCP = 2
    End Sub

    Sub LCDhodinky
    Locate 1, 2
    Print "*"
    If hodH < 10 then
    Print "0"
    End If
    Print hodH
    Print ":"
    If minH < 10 then
    Print "0"
    End If
    Print minH
    End Sub

    Sub ZapisROM
    EPWrite romZ, minutyT
    EPWrite romZ + 1, sekundyT
    romz = romZ + 2
    romC = romZ - 2
    romCP = 2
    If romZ = rom Then
    romZ = 0
    End If
    End Sub

    Sub LCDcyklusT
    Locate 0, 0
    If cyklusTD < 10 Then
    Locate 0, 1
    End If
    Print cyklusTD
    End Sub

    Sub LCDcyklusV
    Locate 1, 0
    If cyklusVD < 10 Then
    Locate 1, 1
    End If
    Print cyklusVD
    End Sub

    Sub LCDcasT
    Locate 0, 3
    'Print hodinyT
    'Print ":"
    If minutyT < 10 Then
    Print "0"
    End If
    Print minutyT
    Print ":"
    If sekundyT < 10 Then
    Print "0"
    End If
    Print sekundyT
    End Sub

    Sub LCDprotopenoT
    Locate 0, 8
    Print " "
    If plamenTH < 10 Then

    ' Print "0"
    End If
    Print plamenTH
    Print ":"
    If plamenTM < 10 Then
    Print "0"
    End If
    Print plamenTM
    Print ":"
    If plamenTS < 10 Then
    Print "0"
    End If
    Print plamenTS
    End Sub

    Sub LCDcasV
    Locate 1, 2
    Print "V"

    'Print hodinyV
    'Print ":"
    If minutyV < 10 Then
    Print "0"
    End If
    Print minutyV
    Print ":"
    If sekundyV < 10 Then
    Print "0"
    End If
    Print sekundyV
    End Sub

    Sub LCDprotopenoV
    Locate 1, 8
    Print " "
    If plamenVH < 10 Then

    ' Print "0"
    End If
    Print plamenVH
    Print ":"
    If plamenVM < 10 Then
    Print "0"
    End If
    Print plamenVM
    Print ":"
    If plamenVS < 10 Then
    Print "0"
    End If
    Print plamenVS
    End Sub

    Sub DobacykluT
    sekundyT = 0
    minutyT = 0
    hodinyT = 0
    Do Until casT < 60
    casT = casT - 60
    minutyT = minutyT + 1
    If minutyT = 60 Then
    minutyT = 0
    hodinyT = hodinyT + 1
    End If
    Loop
    sekundyT = casT
    End Sub

    Sub DobacykluV
    sekundyV = 0
    minutyV = 0
    hodinyV = 0
    Do Until casV < 60
    casV = casV - 60
    minutyV = minutyV + 1
    If minutyV = 60 Then
    minutyV = 0
    hodinyV = hodinyV + 1
    End If
    Loop
    sekundyV = casV
    End Sub

    Sub PlamenDenT
    plamenTS = plamenTS + sekundyT
    plamenTM = plamenTM + minutyT
    plamenTH = plamenTH + hodinyT
    If plamenTS > 59 Then
    plamenTS = plamenTS - 60
    plamenTM = plamenTM + 1
    End If
    If plamenTM > 59 Then
    plamenTM = plamenTM - 60
    plamenTH = plamenTH + 1
    End If
    End Sub

    Sub PlamenDenV
    plamenVS = plamenVS + sekundyV
    plamenVM = plamenVM + minutyV
    plamenVH = plamenVH + hodinyV
    If plamenVS > 59 Then
    plamenVS = plamenVS - 60
    plamenVM = plamenVM + 1
    End If
    If plamenVM > 59 Then
    plamenVM = plamenVM - 60
    plamenVH = plamenVH + 1
    End If
    End Sub

    Sub Odpojeni
    kontakt = kontakt + 1
    If kontakt => prodleva Then
    Set Rele Off
    termostat = 0
    End If
    End Sub

    Sub StartProg
    lcdH = 1
    Locate 0, 0
    cls
    Print "Nastaveni 12:34"
    Locate 1, 0
    Print "00:00"
    Do While lcdH < 5
    tempH = 0
    t5 = 5
    tl1 = 0
    Do While t5 > 0
    If Tlacitko0 = 1 AND tl1 = 1 Then
    tl1 = 0
    End If
    If Tlacitko0 = 0 AND tl1 = 0 Then
    tempH = tempH + 1
    If tempH > 9 then
    tempH = 0
    End If
    t5 = 5
    tl1 = 1
    Wait 100 ms
    End If
    Locate 1, 0
    Print t5
    Print "    "
    Print lcdH
    Print "  "
    Print tempH
    If lcdH = 1 Then
    hodHD = tempH
    hodH = 10 * hodHD
    End If
    If lcdH = 2 Then
    hodH = tempH
    hodH = hodH + 10 * hodHD
    End If
    If lcdH = 3 Then
    minHD = tempH
    minH = 10 * tempH
    End If
    If lcdH = 4 Then
    minH = tempH
    minH = minH + 10 * minHD
    End If
    If hodH > 23 OR minH > 59 Then
    Cls
    Locate 0,2
    Print "Chyba"
    hodH = 0
    minH = 0
    Wait 1 s
    Goto startprog
    End If
    Locate 1, 10
    Print hodH
    Print ":"
    Print minH
    Loop
    lcdH = lcdH + 1
    Loop
    End Sub

    Sub StartProg2
    End Sub

    Sub StartEEPROM
    Repeat (rom-1)/2
    EPRead romCS, TempM
    If TempM <> 255 Then
    romC = romCS - 2
    romZ = romCS
    If romCS = 0 Then
    romCS = rom/2-1
    End if
    Goto Start
    End If
    romCS = romCS + 2
    End Repeat
    End Sub

     
  • Nobody/Anonymous

    Hi,

    There isn't a DAT file for the 16F1847 yet in the chipdata directory but you could edit the 16F1827 dat file and save it as 16F1847.dat. It looks like you would only need to make a few changes for the increased program and data memory and add some extra regions in the  section.

    Prog = 8192
    RAM = 1024
    [FreeRAM]
    20:7F
    A0:EF
    120:16F
    1A0:1EF
    220:26F
    2A0:2EF
    320:36F
    3A0:3EF
    420:46F
    4A0:4EF
    520:56F
    5A0:5EF
    620:64F
    
     
  • Vaclav

    Vaclav - 2011-09-30

    I used latest version of GCB (not graphical) for making .hex file and it looks like there is this problem solved!

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.