Pozdrav svima,
naišao sam na neočekivan problem, naime. Koristim EASYPIC5, 8 MHZ, PCF8283, 18F4620 i 16F887. Program za čitanje vremena ispravno radi na EASYPIC5 pri oba PIC-a. Kada ih premjestim na pločicu s komponentama PIC16F887 odlično radi (čita datum i vrijeme), a 18F1620 stane u procesu procedure read. Kako program radi OK za 16F887, neznam gdje da tražim problem. U početku sam misli kako su problem PULL-UP otpornici, ali izvrsno odrađuju posao pri 16F887. Ima li tko kakvu ideju? Što da mjenjam?
RTC kako objasniti nelogičnost rada
Moderators: pedja089, stojke369, [eDo], trax
Re: RTC kako objasniti nelogičnost rada
Problem moze biti zbog previsoke frekfencije oscilatora, analognih pizdarija na tim pinovima, komparatora i sl...
Re: RTC kako objasniti nelogičnost rada
Prvo hvala,pedja089 wrote:Problem moze biti zbog previsoke frekfencije oscilatora, analognih pizdarija na tim pinovima, komparatora i sl...
vjerojatno si u pravu. Pokušavam pronaći što se sve nalazi na RC3 i RC4, kako bih možda to isključio. Već se nekoliko dana mučim, ali nemam uspjeha. PIC 18F4620 i 18F4550 jednostavno ostaju blokirani odmah na početku procesa. Jednostavno nemam više ideja, svaka pomoć je dobrodošla.
Re: RTC kako objasniti nelogičnost rada
Koliko vidim nista nema na portc3 i c4. Bez seme i koda dzaba sve...
Re: RTC kako objasniti nelogičnost rada
Pozdrav,pedja089 wrote:Koliko vidim nista nema na portc3 i c4. Bez seme i koda dzaba sve...
Kod je originalni kod skinut sa strane Mikroelektronike i on radi.
program Rtc_Read
'*
' * Project name:
' seg4cifstat
' * Copyright:
' (c) mikroElektronika, 2005 - 2006
' * Revision History:
' 20060912:
' - revision 2.
' * Description:
' This code demonstrates how to display a RTC time on
' LCD display
' * Test configuration:
' MCU: PIC16F887
' Dev.Board: EasyPIC5
' Oscillator: HS, 8.000 MHz
' Ext. Modules: RTC on PORTC, LCD on PORTB
' SW: mikroBasic v7.0
' * NOTES:
' PORTC jumper = pull-up
' PORTC LED switch = Off
' *
structure TTime
dim year, months, day, hours, minutes, seconds as byte
end structure
dim TimeRead as TTime
byteRead as byte
yearmod4 as byte
sub procedure Display_Time()
dim txt as string[11]
' output values to LCD display
txt[0] = (TimeRead.day div 10) + 48
txt[1] = (TimeRead.day mod 10) + 48
txt[2] = "/"
txt[3] = (TimeRead.months div 10) + 48
txt[4] = (TimeRead.months mod 10) + 48
txt[5] = "/"
txt[6] = "2"
txt[7] = (TimeRead.year div 100) + 48
txt[8] = ((TimeRead.year mod 100) div 10) + 48
txt[9] = (TimeRead.year mod 10) + 48
txt[10] = 0 ' null to terminate the string
Lcd_Out(1,7,txt)
txt[0] = (TimeRead.hours div 10) + 48
txt[1] = (TimeRead.hours mod 10) + 48
txt[2] = ":"
txt[3] = (TimeRead.minutes div 10) + 48
txt[4] = (TimeRead.minutes mod 10) + 48
txt[5] = ":"
txt[6] = (TimeRead.seconds div 10) + 48
txt[7] = (TimeRead.seconds mod 10) + 48
txt[8] = 0 ' null to terminate the string
Lcd_Out(2,7,txt)
end sub
sub procedure ReadTime()
dim updateYear as byte
updateYear = 0
I2C_start ' issue start signal
I2C_Wr($A0) ' address PCF8583
I2C_Wr(2) ' first word address
I2C_Repeated_Start ' issue repeated start signal
I2C_Wr($A1) ' address PCF8583 for reading R/W=1
byteRead = I2C_Rd(1) ' read seconds byte
TimeRead.seconds = (byteRead >> 4)*10 + byteRead and 0x0F ' transform seconds
while I2C_Is_Idle = 0 ' this lines are not neccessary in new versions
nop ' starting from mikroPascal 6.0.0.1
wend
byteRead = I2C_Rd(1) ' read minutes byte
TimeRead.minutes = (byteRead >> 4)*10 + byteRead and 0x0F ' transform minutes
while I2C_Is_Idle = 0
nop
wend
byteRead = I2C_Rd(1) ' read hours byte
TimeRead.hours = (byteRead >> 4)*10 + byteRead and 0x0F ' transform hours
while I2C_Is_Idle = 0
nop
wend
byteRead = I2C_Rd(1) ' read year/day byte
TimeRead.day = ((byteRead and %00110000) >> 4)*10 + byteRead and 0x0F ' transform day
yearmod4 = (byteRead and %11000000) >> 6 ' get year mod 4 from RTC
while I2C_Is_Idle = 0
nop
wend
byteRead = I2C_Rd(0) ' read weekday/months byte
TimeRead.months = ((byteRead and %00010000) >> 4)*10 + byteRead and 0x0F ' transform months
while I2C_Is_Idle = 0
nop
wend
I2C_Stop
I2C_start ' issue start signal
I2C_Wr($A0) ' address PCF8583
I2C_Wr($10) ' first word address
I2C_Repeated_Start ' issue repeated start signal
I2C_Wr($A1) ' address PCF8583 for reading R/W=1
byteRead = I2C_Rd(0) ' read year
if yearmod4 <> (byteRead mod 4) then ' check if year is incremented in RTC
Inc(byteRead) ' in this case the new value should be written to RTC RAM at address 16(0x10)
updateYear = 1
end if
TimeRead.year = byteRead
while I2C_Is_Idle = 0
nop
wend
I2C_Stop
if updateYear > 0 then
I2C_Start ' issue start signal
I2C_Wr($A0) ' address PCF8530
I2C_Wr($10) ' start from word at address 16
I2C_Wr(TimeRead.year) ' write year to RAM
I2C_Stop ' issue stop signal
end if
end sub
sub procedure MainInit()
Lcd_Config(PORTB, 3, 2, 1, 0, PORTB, 4, 7, 5) ' Lcd_Init_EP5, see Autocomplete
Lcd_Cmd(LCD_CLEAR)
Lcd_Cmd(LCD_CURSOR_OFF)
LCD_Out(1,1,"Date: / /")
LCD_Out(2,1,"Time: : :")
I2C_Init(100000) ' initialize I2C
end sub
main:
ADCON1 = $0F
MainInit()
while true
ReadTime()
Display_Time()
Delay_ms(1000)
wend
end.
Šema je također skinuta sa strane Mikroelektronike (RTC sa PCF8583, PULL-UP otpornici 10 K na 5 i 6 pinu RTC čipa, otpornici na pinovima 5,6 i 7 su 1 K i dobivaju napon sa diode BAT43). Tako PIC 16F887 i F18F4620 rade na EASYPIC 5 i RTC na mojoj PCB. Kada premjestim PIC-eve na gotovu PCB radi samo 16F887, a drugi se blokira. Ja sam lud od pokušaja, spojio sam promjenjive otpornike umjesto PULL-UP i pokušao dobiti rezultat, ali ništa.
- Attachments
-
- rtc1.JPG (20.39 KiB) Viewed 2676 times