ok knocked off this line
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
and its only giving the warning :-Argument out of range. Least significant bits used
ok knocked off this line
@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
and its only giving the warning :-Argument out of range. Least significant bits used
If I remove the "e"
And remove the space atCode:lcdout $FE,1, " Appuyé sur Start "
RTCYear
It compiles.Code:I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCY ear,RTCCtrl] 'read clock
Dave
Always wear safety glasses while programming.
Hi I finally got it to compile. Now I have a small problem writing to memory. Its actually not writing. and on the LCD its always showing 0000
I have A0 and A1 to ground and A2 to 5v. on the eeprom 24LC1025, pins are configued correctly, is there anything in the program that will not allow a writing ???
Code:'///////////////////////// '// EEPROM test program '// Using the PIC16F887 '// '///////////////////////// '///////////////////////// '// Define section // '///////////////////////// '@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF '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 '///////////////////////// '// PIN configuration // '///////////////////////// TRISB = %00000000 ' Set PORTB to all output TRISA = %11111111 ' Set PORTA to all input TRISC = %11000000 ' Set PORTC to all output '/////////////////////////////////////////////// '// Variable Declaration and initialization // '/////////////////////////////////////////////// Battery_Switch var byte i var byte j var byte Battery_Charge_Counter var byte SDApin var PORTC.4 ' RTC data SCLpin var PORTC.3 ' RTC clock bat var byte Write_Address var byte RTCSec var byte :RTCMin var byte :RTCHour var byte :RTCWDay var byte :RTCDay var byte :RTCMonth var byte :RTCYear var byte :RTCCtrl var byte lcdout $FE,1, "Bienvenue" lcdout $FE,$C0, "Welcome" pause 1500 I2CWRITE SDApin,SCLpin,$A0,$00,[$03,$02,$05,$00,$00,$00,$00,$00] ' Write to memory pause 20 '//////////////////////////////////////////////////// '////////////////// PROGRAM ///////////////////////// '//////////////////////////////////////////////////// Mainloop: lcdout $FE,1, "Appuye sur Record" lcdout $FE,$C0, "ou sur Show" pause 200 if PORTC.7 =0 then 'always 5v, push button to gnd j=1 I2CRead SDApin,SCLpin,$A0,$00,[RTCSec,RTCMin,RTCHour,RTCDay] lcdout $FE,1, " Time ", dec j lcdout $FE,$C0, dec RTCDay, dec RTCHour, dec RTCMin, dec RTCSec pause 2000 Endif goto Mainloop End
O by the way, while compiling another program, MicroCode studio does not seem to tell me where the error is unlike compiling in Picbasic pro. It only gives me this error:
least significant bits used
wow really helpful.... 600 lines of code![]()
Good morning.
Ok a good night sleep was excellent. For the first message last night I posted at 23:03, I believe I may have to play around with the registers.. SSPCON... or perhaps others.
Also, I may have to use A0 for write and A1 for read on the 24LC1025 EEPROM chip. I will try that tonight.
For the second message, I still have no idea, the compiler just tell me there is a problem somewhere in the code. There must be a way ton configure MicroCode studio to be more specific, is there ?
K
Last edited by lerameur; - 2nd December 2010 at 13:41.
Hi I copied this program from a thread. It is suppose to be working, but I keep getting zeros in on my LCD:
anyone ?
Code:'///////////////////////// '// EEPROM and test program '// Using the PIC16F887 '// '///////////////////////// '///////////////////////// '// Define section // '///////////////////////// '@ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF 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 DB0 var byte[8] TRISB= %11111111 TRISC= %00000000 gosub write_eeprom read_eeprom: ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control I2CREAD SDA,SCL,$A1,$00,[STR DB0\8] ' Read 8 bytes from EEPROM lcdout $fe,1,"Time=",hex2 DB0[2],":",hex2 DB0[1],":",hex2 DB0[0] 'bit 0=sec, bit 1=min, bit 2=hrs lcdout $fe,$c0,"Date=",hex2 DB0[4],":",hex2 DB0[5],":",hex2 db0[6] 'bit 4=day, bit 5=month, bit 6=year pause 50 goto read_eeprom end Write_eeprom: ' Set time & date to 19:00:00 14th Feb 201 pause 1000 I2CWRITE SDA,SCL,$A0,$00,[$00,$00,$19,$7,$14,$2,$10,$80] ' Write to EEPROM pause 10 RETURN
humm
ok
from this thread:http://www.picbasic.co.uk/forum/showthread.php?t=12671
The huy has a pic16F887 like mine, but his SDA and SCL are on portB2 and B1... My datasheet tells me C4 and C3......
Bookmarks