PDA

View Full Version : Alguien que me ayude por favor...



Payatronico
- 18th September 2006, 23:34
I use PBP recently, I generally used assembler or HT-Pic, I have two problems mainly:

1. - the LCD doesn't initialize correctly at the beginning of the program, I have to hope the program restarts and after that the second line appears
2. - the communication with the memory doesn't work, this communication doesn't write neither reads anything, the pin number 7 is connect to ground and the pins 1 2 and 3 they are also to ground, I have resistances to VCC in SDA and SCL 1K and I have try with resistance from 10 to 50K.
The crystal that I use is of 20MHz
the pic is the 16f877
SCL=PORTC,3
SDA=PORTC,4
the memory is 24LC08B
the program is this:

Define LCD_DREG PORTD 'puerto de comunicacion con el lcd
Define LCD_DBIT 0 'inicio en el bit 0 del puerto D
Define LCD_RSREG PORTD 'puerto de control RS
Define LCD_RSBIT 5 'bit RS
Define LCD_EREG PORTD 'puerto de control E
Define LCD_EBIT 7 'bit E
Define LCD_RWREG PORTD 'puerto de control RW
Define LCD_RWBIT 6 'bit RW
Define LCD_BITS 4 'bits de datos
define LCD_LINES 2 'lineas en el LCD
define I2C_SLOW 1 'i2c para cristal rápido
define OSC 20 'velocidad del cristal
scl var PORTC.3
sda var PORTC.4
dato var byte 'dato a escribir
dire var byte 'dirección del dato
dato=250
Pause 500 ' espero que el lcd inicie
lcdout $fe,1 'limpia el LCD
pause 100
lcdout $fe,$0c 'no tengo idea que hace
pause 1000
for dire=0 to 10
lcdout $fe,1 'limpia el LCD
i2cwrite sda,scl,$a0,dire,dato 'escribe el dato en el LCD en la direccion dire
dato=dato-1
lcdout "escribe"
lcdout $fe,$c0
lcdout #dire,":",#dato
pause 1000
next dire
for dire=0 to 10
lcdout $fe,1
i2cwrite sda,scl,$a0,dire,dato
lcdout "lee"
lcdout $fe,$c0
lcdout #dire,":",#dato
dato=0
pause 1000
next dire

help me please
ayudame gebuuuuuuus que estoy que me mato con este programa puerco...

ATT: Payatronico

mister_e
- 19th September 2006, 05:38
I never used RW pin on a PBP prog but just make sure the PIN is set to LOW first.

LOW PORTD.6

This


i2cwrite sda,scl,$a0,dire,dato


Should be


i2cwrite sda,scl,$a0,dire,[dato]



Also make sure your config fuses are correctly set before programming the PIC (HS OSC, LVP OFF..etc etc etc)


this communication doesn't write neither reads anything,

Euh... i don't see any I2CREAD but just I2CWRITE :( Also if the config fuses are not correctly set in your code or before programming the PIC, it will never work.