Getting access to the build in RTCC

General discussion on mikroBasic PRO for PIC32.
Author
Message
Hurtz Hurty
Posts: 176
Joined: 12 Aug 2007 01:33

Re: Getting access to the build in RTCC

#16 Post by Hurtz Hurty » 08 Aug 2011 06:05

Hello Helmut,
I saw that the MiniPIC 32bBoard is designed with a PIC32MX534F064H ...
Maybe you have to compile with this one.
Sometimes you can't see the forest for the trees.

Hurtz Hurty
Posts: 176
Joined: 12 Aug 2007 01:33

Re: Getting access to the build in RTCC

#17 Post by Hurtz Hurty » 08 Aug 2011 06:06

Hello Helmut,
I saw that the MiniPIC 32bBoard is designed with a PIC32MX534F064H ...
Maybe you have to compile with this one.
Sometimes you can't see the forest for the trees.

Hurtz Hurty
Posts: 176
Joined: 12 Aug 2007 01:33

Re: Getting access to the build in RTCC

#18 Post by Hurtz Hurty » 08 Aug 2011 07:20

Helmut, please try this:
erase the pic before flashing it, this helped me sometimes and/or
power your board off & on again, sometimes the reset didn't worked.
Sometimes you can't see the forest for the trees.

Helmut
Posts: 252
Joined: 02 Aug 2006 12:58
Location: Flensburg Germany

Re: Getting access to the build in RTCC

#19 Post by Helmut » 08 Aug 2011 14:29

Thank you!!

I have no time right now.

Did from the TFT-MMB unsolder the 460 microprocessor and a soldering with 795 µP again, because I want to use the CAN_Bus.

Can it be that the 32kHz quartz crystals are to big? Perhaps <22pF ?

Best regards,
Helmut
PS.: I see your code for VTFT: very good!!

Helmut
Posts: 252
Joined: 02 Aug 2006 12:58
Location: Flensburg Germany

Re: Getting access to the build in RTCC

#20 Post by Helmut » 09 Aug 2011 16:30

So, after i read this,
http://www.mikroe.com/forum/viewtopic.p ... 88#p163288
i try the RTCC-Code without Bootlader !!!

The code is running Reset is not the trouble.

With bootlader: Nothing...

So i erase the bootlader and program without this tool...
Waiting for the Update, i hope it's comming

Best regards
Helmut

Hurtz Hurty
Posts: 176
Joined: 12 Aug 2007 01:33

Re: Getting access to the build in RTCC

#21 Post by Hurtz Hurty » 09 Aug 2011 16:39

Hi Helmut,

if you uncomment this line in the code:

Code: Select all

    'OSCCONSET = 2             'enable Secondary Oscillator
maybe it works, because the osc. is enabled again (1. by conf. bits)
at runtime.
Sometimes you can't see the forest for the trees.

Helmut
Posts: 252
Joined: 02 Aug 2006 12:58
Location: Flensburg Germany

Re: Getting access to the build in RTCC

#22 Post by Helmut » 09 Aug 2011 20:36

@RTCC_Selbsthilfegruppe

At now, here is my Code with 795er µP.
There is double writing from text into tft, i dont know why....

Best regards
Helmut

Code: Select all

program RTCC_main

  include TFT_Init
  
  dim time_ as longword
  dim date_ as longword
  
  dim Label1_Caption, Label2_Caption as string[7]
      AnzeigeWoTag as string[15]
      txt as char[3]
  
  main:
    Start_TFT()
    
    TFT_Fill_Screen(CL_BLACK)
    
    time_ = 0x23590000        ' set time to 18 hr, 33 min, 33 sec  time_ = 0x18333300
    date_ = 0x11080802        ' set date to Monday 07 Aug 2011

    ' RTCC registers unlock procedure
    SYSKEY = 0xAA996655       ' Write first unlock key to SYSKEY
    SYSKEY = 0x556699AA       ' Write second unlock key to SYSKEY

    RTCWREN_bit = 1           ' RTC Value registers can be written to by the user
    ON__RTCCON_bit = 0        ' Turn off the RTCC module  ON__RTCCON_bit = 0        ' Turn off the RTCC module
    
    while(RTCCON and 0x40)    ' Wait for clock to be turned off
      asm
        nop
      end asm
    wend

    RTCTIME = time_           ' Set time
    RTCDATE = date_           ' Set date
 ' ############################## vom Forum  ####################
 ' enable secondary oscillator bit 5 FSOSCEN: Secondary Oscillator Enable bit
 '1 = Enable Secondary Oscillator
 '0 = Disable Secondary Oscillator
   SOSCEN_bit = 1       ';
    delay_ms(100)             'startup time for crystal min. 36 ms

    ON__RTCCON_bit = 1        ' Turn on the RTCC module
    RTCWREN_bit = 0           ' RTC Value registers can't written to by the user
    Label1_Caption = ""
    
      while TRUE
        time_ = RTCTIME
        date_ = RTCDATE
        ' #Wirkungslos ev weil kein schreib/lese Recht:
        'if   SOSCRDY=1 then TFT_Set_Font(@TFT_defaultFont, CL_PURPLE, FO_Vertical) end if
        'gleiches Bit -> anderer Name
        'if   OSCCON.22=0 then TFT_Set_Font(@TFT_defaultFont, CL_PURPLE, FO_HORIZONTAL) end if
        
        ' Dieses hier ist nur um Zeichen zu löschen:
        TFT_Set_Font(@TFT_defaultFont, CL_BLACK, FO_HORIZONTAL)
        TFT_Write_Text(Label1_Caption, 130, 130)
        tft_write_text(AnzeigeWoTag, 130, 150)
        TFT_Write_Text(Label2_Caption, 130, 170)
        'Uhr
        ByteToStr(highest(time_) div 16,txt)   'high nibble of hours
        Label1_Caption[0] = txt[2]
        'Datum
        ByteToStr(highest(Date_) div 16,txt)   'high nibble of hours
        Label2_Caption[6] = txt[2]
        'Uhr
        ByteToStr(highest(time_) mod 16,txt)   'low nibble of hours
        Label1_Caption[1] = txt[2]
        'Datum
        ByteToStr(highest(Date_) mod 16,txt)   'low nibble of hours
        Label2_Caption[7] = txt[2]
        'Uhr
        Label1_Caption[2] = ":"
        'Datum
        Label2_Caption[2] = "."
        'Uhr
        ByteToStr(higher(time_) div 16,txt)   'high nibble of minutes
        Label1_Caption[3] = txt[2]
        'Datum
        ByteToStr(higher(Date_) div 16,txt)   'high nibble of minutes
        Label2_Caption[3] = txt[2]
        'Uhr
        ByteToStr(higher(time_) mod 16,txt)   'low nibble of minutes
        Label1_Caption[4] = txt[2]
        'Datum
        ByteToStr(higher(date_) mod 16,txt)   'low nibble of minutes
        Label2_Caption[4] = txt[2]
        'Uhr
        Label1_Caption[5] = ":"
        'Datum
        Label2_Caption[5] = "."
        'Uhr
        ByteToStr(hi(time_) div 16,txt)   'high nibble of seconds
        Label1_Caption[6] = txt[2]
        'Datum
        ByteToStr(hi(Date_) div 16,txt)   'high nibble of seconds
        Label2_Caption[0] = txt[2]
        'Uhr
        ByteToStr(hi(time_) mod 16,txt)   'low nibble of seconds
        Label1_Caption[7] = txt[2]
        'Datum
        ByteToStr(hi(Date_) mod 16,txt)   'low nibble of seconds
        Label2_Caption[1] = txt[2]         'Datum Format ist gedreht!
        'Wochen Tag
       ' ByteToStr(Date_ and 0x00000F,Datum)
        select case (Date_ and 0x00000F)
               case 0 AnzeigeWoTag = "Sonntag   , der"
               case 1 AnzeigeWoTag = "Montag    , der"
               case 2 AnzeigeWoTag = "Dienstag  , der"
               case 3 AnzeigeWoTag = "Mittwoch  , der"
               case 4 AnzeigeWoTag = "Donnerstag, der"
               case 5 AnzeigeWoTag = "Freitag   , der"
               case 6 AnzeigeWoTag = "Samstag   , der"
        end select
        ' Zeichen schreiben
        TFT_Set_Font(@TFT_defaultFont, CL_Blue, FO_HORIZONTAL)
        TFT_Write_Text(Label1_Caption, 130, 130)
        TFT_Write_Text(AnzeigeWoTag, 130, 150)
        TFT_Write_Text(Label2_Caption, 130, 170)
        delay_ms(1000)
      wend
end.

Hurtz Hurty
Posts: 176
Joined: 12 Aug 2007 01:33

Re: Getting access to the build in RTCC

#23 Post by Hurtz Hurty » 09 Aug 2011 21:09

@ RTCC TherapieGruppe

Hi Helmut,
in the moment I'm to tired & a bit to lazy to have a concentrated look at your code BUT,
here is an update of my example with date & day of the week and it's absolutely flicker-free.
Maybe it's faster when you adapt it again for your needs.

Code: Select all

program RTCC_main

  include TFT_Init

  dim time_ as longword
  dim date_ as longword

  dim Label1_Caption, Label1_Caption1  as string[22]
  dim txt as char[3]
  dim i, j as byte
  dim k as integer

  typedef WD as char[2]
  const DOW as WD[7] = ("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa")

  main:
    Start_TFT()

    TFT_Fill_Screen(CL_BLACK)

    time_ = 0x23595500        ' set time to 18 hr, 33 min, 33 sec  time_ = 0x18333300
    date_ = 0x54123105        ' set date to Monday 07 Aug 2011

    ' RTCC registers unlock procedure
 
    SYSKEY = 0xAA996655       ' Write first unlock key to SYSKEY
    SYSKEY = 0x556699AA       ' Write second unlock key to SYSKEY

    RTCWREN_bit = 1           ' RTC Value registers can be written to by the user

    ON__RTCCON_bit = 0        ' Turn off the RTCC module  ON__RTCCON_bit = 0        ' Turn off the RTCC module

    while(RTCCON and 0x40)    ' Wait for clock to be turned off
      asm
        nop
      end asm
    wend

    RTCTIME = time_           ' Set time
    RTCDATE = date_           ' Set date

    OSCCONSET = 2             'enable Secondary Oscillator
    delay_ms(50)

    ON__RTCCON_bit = 1        ' Turn on the RTCC module

    for i = 0 to 22
      Label1_Caption1[i] = ""
      Label1_Caption[i]  = ""
    next i

      while TRUE
        time_ = RTCTIME
        date_ = RTCDATE

        Label1_Caption = DOW[lo(date_)]

        Label1_Caption[02] = " "

        ByteToStr(hi(date_) div 16,txt)   'high nibble of hours
        Label1_Caption[03] = txt[2]
        ByteToStr(hi(date_) mod 16,txt)   'low nibble of hours
        Label1_Caption[04] = txt[2]

        Label1_Caption[05] = "."

        ByteToStr(higher(date_) div 16,txt)   'high nibble of minutes
        Label1_Caption[06] = txt[2]
        ByteToStr(higher(date_) mod 16,txt)   'low nibble of minutes
        Label1_Caption[07] = txt[2]

        Label1_Caption[08] = "."

        Label1_Caption[09] = "2"
        Label1_Caption[10] = "0"
        ByteToStr(highest(date_) div 16,txt)   'high nibble of hours
        Label1_Caption[11] = txt[2]
        ByteToStr(highest(date_) mod 16,txt)   'low nibble of hours
        Label1_Caption[12] = txt[2]

        Label1_Caption[13] = " "

        ByteToStr(highest(time_) div 16,txt)   'high nibble of hours
        Label1_Caption[14] = txt[2]
        ByteToStr(highest(time_) mod 16,txt)   'low nibble of hours
        Label1_Caption[15] = txt[2]

        Label1_Caption[16] = ":"

        ByteToStr(higher(time_) div 16,txt)   'high nibble of minutes
        Label1_Caption[17] = txt[2]
        ByteToStr(higher(time_) mod 16,txt)   'low nibble of minutes
        Label1_Caption[18] = txt[2]

        Label1_Caption[19] = ":"

        ByteToStr(hi(time_) div 16,txt)   'high nibble of seconds
        Label1_Caption[20] = txt[2]
        ByteToStr(hi(time_) mod 16,txt)   'low nibble of seconds
        Label1_Caption[21] = txt[2]

        J = 80
        for i = 0 to 21
         if Label1_Caption1[i] = Label1_Caption[i] then
            else
             TFT_Set_Font(@TFT_defaultFont, CL_BLACK, FO_HORIZONTAL)
             TFT_Write_Char(Label1_Caption1[i], j, 0)

             TFT_Set_Font(@TFT_defaultFont, CL_GREEN, FO_HORIZONTAL)
             TFT_Write_Char(Label1_Caption[i], j, 0)
          end if

          if (Label1_Caption[i] = ".") or (Label1_Caption[i] = ":") then
             j = j + 5
            else
             j = j + 8
          end if
        next i

        Label1_Caption1 = Label1_Caption

        delay_ms(1000)
      wend
end.
OK, bis denne ...
Sometimes you can't see the forest for the trees.

Helmut
Posts: 252
Joined: 02 Aug 2006 12:58
Location: Flensburg Germany

Re: Getting access to the build in RTCC

#24 Post by Helmut » 10 Aug 2011 07:22

@filip
Tanks for this info: Post subject: Re: sample RTCC on MINI-32 doesn't led blinking

@ RTCCTherapiegruppe
for english patient:@RTCCgroup therapy

good code, thank you.

And now, yet the work onewire 18B20 code on the PIC32 795th
So far I've done it with no code onewire.

A brandnew OneWiregroup therapy ;-)



Best regards
Helmut

Post Reply

Return to “mikroBasic PRO for PIC32 General”