![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi everyone, im working in a real time clock proyect with a 16F876 coding it with assembler. According with the datasheet of both IC's, the code seems to be fine, the problem is when i simulated it in Proteus Isis (7.4) it just doesnt work. The DS1307 sends the corresponding ack signals, but i cant write any register of it. Does anyone have an asm code working with this IC? thanks you very much PD: it has to be in asm code . thanks
| |
| |
| | #2 |
|
Source code for this project which uses a DS1307 Microchip PIC based central heating programmer with serial CLI interface is here http://picprojects.org.uk/projects/chc/source/chp.zip I think the DS1307 bits are in TimeControl.inc and i2c_driver.inc | |
| |
| | #3 |
|
can you post the code you have made? You are simulating in Proteus Isis. Why not on a breadboard? I understand the benefit but its more fun on breadboard. Anyway post some code and well see what we can find.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #4 |
|
Hi again here is the code, sorry the spanish comments i hope you understand what im trying to do ![]() Code: LIST P=16F876A #INCLUDE P16F876.INC #define LCDE PORTC,0 ;Habilitación del LCD #define LCDRS PORTC,1 ;Selección de modo del LCD ORG 00H GOTO INICIO ORG 04H GOTO ISR ORG 05H PCL equ 0x02 LCDlinea1 equ H'0080' LCDlinea2 equ H'00c0' LCDCLR equ H'0001' LCDCasa equ H'0002' LCDInc equ H'0006' LCDDec equ H'0004' LCDOn equ H'000C' LCDOff equ H'0008' CursorOn equ H'000E' CursorOff equ H'000C' CursBlink equ H'000F' LCDIzda equ H'0018' LCDDecha equ H'001C' CursIzda equ H'0010' CursDecha equ H'0014' LCDFuncion equ H'0038' LCDCGRAM equ H'0040' RTCWRT equ b'11010000' RTCRD equ b'11010001' AUX equ H'0021' AUX1 equ H'0022' tiempo1 equ 0x23 ;Usados para temporizar tiempo2 equ 0x24 SEG equ H'0025' ; usados para guardar los MIN equ H'0026' ; datos que HOR equ H'0027' ; se DIA equ H'0028' ; muestran FECHA equ H'0029' ; en MES equ H'002A' ; el AÑO equ H'002B' ; LCD DIRI2C equ H'002C' ; DATO TEMPORAL A SER ENVIADO A TRAVES DEL BUS I2C rtc_SEG equ H'00' rtc_MIN equ H'01' rtc_HOR equ H'02' rtc_DIA equ H'03' rtc_FECHA equ H'04' rtc_MES equ H'05' rtc_AÑO equ H'06' rtc_CONTROL equ H'07' INICIO BCF STATUS,RP0 BCF STATUS,RP1 BCF ADCON0,0 BSF STATUS,RP0 MOVLW H'06' MOVWF ADCON1 BCF STATUS,RP1 MOVLW H'D5' MOVWF OPTION_REG CLRF TRISA CLRF TRISB CLRF TRISC BSF TRISC,3 BSF TRISC,4 CLRF PIE1 CLRF PIE2 BCF STATUS,5 CLRF PIR1 CLRF PIR2 CLRF PORTA CLRF PORTB MOVLW .4 CALL Pausa5ms CALL INILCD CALL INIMSSP MOVLW .0 ;EMPIEZO DESDE LOS SEGUNDOS CALL I2CSTARTW MOVLW H'51' CALL I2CDATOW MOVLW H'45' CALL I2CDATOW MOVLW H'23' CALL I2CDATOW MOVLW H'01' CALL I2CDATOW MOVLW H'14' CALL I2CDATOW MOVLW H'01' CALL I2CDATOW MOVLW H'99' CALL I2CDATOW MOVLW H'10' CALL I2CDATOW CALL I2CSTOPACK CLRF STATUS MOVLW .10 CALL Pausa5ms MOVLW H'FF' CALL DATO MOVLW H'57' CALL CONTROL MOVLW H'FF' CALL DATO MOVLW H'C0' CALL CONTROL MOVLW H'FF' CALL DATO MOVLW H'67' CALL CONTROL MOVLW H'FF' CALL DATO NOP GOTO $-1 ;*************RUTINA DE SERVICIO DE INTERRUPCION***************** ISR RETFIE ;*********************BUS I2C*********** INIMSSP CLRF STATUS MOVLW H'28' MOVWF SSPCON ;HABILITA PINES SDA Y SCL Y CONFIGURA AL PIC COMO I2C MASTER BSF STATUS,RP0 MOVLW .9 MOVWF SSPADD; VALOR NECESARIO PARA QUE EL CLOCK SEA DE 100KHZ (CK=OSC/4(SSPADD+1)) OK BSF SSPSTAT,7; TRANSMISION A 100KHZ BCF SSPCON2,5; VALOR DEL ACK CUANDO TERMINA DE RECIBIR UN BYTE (1 ES NACK) BCF PIE1,3 BCF STATUS,RP0 BCF PIR1,3 RETURN I2CSTARTW BCF STATUS,RP1 ; ESCRIBIR EN W LA PRIMER DIRECCION DE MEMORIA DONDE SE QUIERE ESCRIBIR Y LLAMAR BCF STATUS,RP0 MOVWF DIRI2C BSF STATUS,RP0 BSF SSPCON2,0; START CALL I2CHEK ; EL MODULO ESTA OCUPADO? BCF STATUS,RP0 MOVLW RTCWRT ; DIRECCION DEL RTC MAS BIT DE ESC 0 MOVWF SSPBUF CALL I2CHEK ; EL MODULO ESTA OCUPADO? MOVF DIRI2C,W ; PRIMER DIRECCION DONDE VOY A ESCRIBIR MOVWF SSPBUF CALL I2CHEK ; EL MODULO ESTA OCUPADO? RETURN I2CDATOW ; CARGAR EN W EL SIG DATO Y LLAMAR CALL I2CHEK BCF STATUS,RP0 BCF STATUS,RP1 MOVWF SSPBUF CALL I2CHEK RETURN I2CSTOPACK BCF STATUS,RP1 BSF STATUS,RP0 BCF SSPCON2,5 ;ANTES DEL STOP HABRA UN ACK SI ESTUVIESE EN RECIBIR CALL I2CHEK BSF SSPCON2,2; STOP CALL I2CHEK RETURN I2CSTOPNACK BCF STATUS,RP1 BSF STATUS,RP0 BSF SSPCON2,5 ;NACK ANTES DEL STOP BSF SSPCON2,4; NACK CALL I2CHEK BSF SSPCON2,2 ; STOP CALL I2CHEK RETURN I2CHEK BCF STATUS,RP1 BSF STATUS,RP0 BTFSC SSPSTAT,2; TRANSMICION EN PROGRESO? GOTO $-1;ENTONCES ESPERA VER MOVF SSPCON2,W ;CHEQUEA ANDLW H'1F' ;QUE NO ESTE HACIENDO BTFSS STATUS,Z ;OTRA TAREA GOTO VER BCF STATUS,RP0 RETURN ;*************RUTINA DE ESCRITURA Y CONTROL LCD******* CONTROL BCF LCDRS GOTO CHEK DATO BSF LCDRS CHEK CLRF STATUS MOVWF PORTB BSF STATUS,RP0 BSF TRISB,7 CLRF STATUS BSF LCDE NOP BCF LCDE NOP BTFSC PORTB,7 GOTO $-1 BSF STATUS,RP0 BCF TRISB,7 CLRF STATUS RETURN ;******INICIACION DEL LCD*********** INILCD CLRF STATUS MOVLW .6 MOVWF AUX1 MOVF AUX1,0 ;AUX1 -> W CALL LISTA1 CALL CONTROL CLRF STATUS DECFSZ AUX1 GOTO $-4 MOVLW CursorOff CALL CONTROL RETURN LISTA1 ADDWF PCL,1 RETLW CursBlink RETLW LCDCLR RETLW CursorOn RETLW LCDOn RETLW LCDInc RETLW LCDFuncion ;******RUTINAS DE TEMPORIZACION********* Pausa5ms CLRF STATUS MOVWF AUX HOLD clrf INTCON movlw .178 movwf TMR0 btfss INTCON,2 goto $-1 DECFSZ AUX GOTO HOLD return END thank you very much ![]() | |
| |
| | #5 |
|
ok thanks ill test this out as much as i can and hopefully can help
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #6 |
|
Hey add a 22k resistor from MCLR to VCC (not straight though) also in the code you need to set the config like Code: LIST P=16F876A #INCLUDE P16F876.INC __CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _LVP_ON & _CPD_OFF EDIT Sorry i cant help much more my asm is sluggish and i get lost in it quick. If it was C then it would have been fixed
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 14th January 2009 at 05:19 PM. | |
| |
| | #7 |
|
ok atomsoft i see what can i do, thank you very much!!!!!! ![]() | |
| |
| | #8 |
|
im sorry i couldnt help you much more on this but heh ASM is spooky sometimes with larger projects like this.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #9 |
|
The only thing I can see wrong is you don't set the ACKEN bit in one of your routines, Code: I2CSTOPACK bcf STATUS,RP1 bsf STATUS,RP0 bcf SSPCON2,5 ;ANTES DEL STOP HABRA UN bsf SSPCON2,4 ; Added ACK SI ESTUVIESE EN RECIBIR call I2CHEK bsf SSPCON2,2 ; STOP call I2CHEK return I2CSTOPNACK bcf STATUS,RP1 bsf STATUS,RP0 bsf SSPCON2,5 ;NACK ANTES DEL STOP bsf SSPCON2,4 ; NACK call I2CHEK bsf SSPCON2,2 ; STOP call I2CHEK return | |
| |
| | #10 |
|
pommie ... what about the config stuff? doesnt he have to set it?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #11 |
| | |
| |
| | #12 |
|
Actually i took that config of the templates that come with MPLAB LD just changed the OSC to XT since its most likely @ 4 Mhz EDIT burnediode off topic some but wanted to know if you have or know where i can get a MODEL for Isis for a DS1306. I would love to rebuild my clock in it. Looks like fun and can make more changes and stuff faster and test better.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 15th January 2009 at 02:38 AM. | |
| |
| | #13 | |
|
first of all thanks Quote:
Atomsoft... i cant help you with that , i really dont know where to find it.im thinking, is there any chance that proteus doesnt have a simulating model for DS1307? and about the config the compiler throw me this msg Error[126] C:\ELECTRONICA\PROYECTOS ASSEMBLER\IMORET.ASM 5 : Argument out of range (not a valid config register address) what!? | ||
| |
| | #14 |
|
post the config line. ... well post entire line 5
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #15 |
|
That config line should work fine. Is it after the list and include lines? Also, I have notice that you are specifying two different chips, Code: LIST P=16F876A #INCLUDE P16F876.INC Mike. | |
| |
|
| Tags |
| asm, ds1307, handling |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| LED Pulse Handling Capability | Stellarcore | General Electronics Chat | 5 | 30th June 2008 05:19 AM |
| handling clock pulse | freezemenot | Micro Controllers | 1 | 20th January 2008 06:32 PM |
| Need some tricks in VB handling | Alex_rcpilot | General Electronics Chat | 8 | 16th October 2005 12:11 PM |
| HANDLING THE INTERRUPT. | alamy | Micro Controllers | 6 | 26th March 2005 04:37 PM |
| R.P.S's Rated Power Handling. | Screech | General Electronics Chat | 3 | 8th June 2004 09:41 AM |