Hi all.
I want to finish this very simple PIC 16F628A code but I have a mistake I don't understand :
What I need is to read the PortB value (0 - 255) but PortB.3 and PortB.4 return zero everytime.
8 Dipswitches are connected on PortB to VCC and the total value is reported on an serial LCD screen.
I don't use X-tal and nothing else my LCD is connected on the PIC for the moment except 2 resistors between VCC and PortA.2 / PortA.3 for a future I2C use.
My serial transmission is okay @9600 without X-tal and my issue is not there.
I try since 3 days and now all my hairs are on the floor ;O)
I think I need something to add in the head of the code but what ?
Any help is welcome.
Thanx a lot and cheers from France.
Here is my code :
Code:@ device PIC16F628A, INTRC_OSC_NOCLKOUT, wdt_off, pwrt_on, mclr_off, protect_off 'Utilisable avec PM Include "modedefs.bas" ' Mode definitions for Serout CMCON = 7 ' Turn OFF all analog features, all is now digital ; VRCON = 0 ' Disable A/D Voltage reference, I don't need that in this code ; INTCON.7 = 0 ' Disable interrupts, I don't need that in this code Define OSC 4 ' Set Xtal Frequency DEFINE I2C_SCLOUT 1 ' I'll use I2C communication Clear TRISA = 0 ' All Port A output TRISB = 255 ' All PortB input LOW PORTA ' SYMBOL SDA = PORTA.2 ' I2C SDA (R 10k to VCC) SYMBOL SCL = PORTA.3 ' I2C SCL (R 10K to VCC) SYMBOL DIP1 = PORTB.0 SYMBOL DIP2 = PORTB.1 SYMBOL DIP3 = PORTB.2 SYMBOL DIP4 = PORTB.3 SYMBOL DIP5 = PORTB.4 SYMBOL DIP6 = PORTB.5 SYMBOL DIP7 = PORTB.6 SYMBOL DIP8 = PORTB.7 LCDPIN Var PORTA.1 ' Serial LCD ADDR1 VAR BYTE ADDR1 = $C2 ' Fixed I2C address for PLL 5055 PLLBASE VAR WORD TMP VAR WORD PLL VAR WORD PLLLO VAR PLL.LOWBYTE PLLHI VAR PLL.HIGHBYTE FMHZ var WORD FKHZ var WORD PLLBASE = 19200 ' Lowest freq BAUDRATE CON N9600 ' For use with LCD pause 1000 ' wait for the LCD to startup MAIN: TMP = PORTB * 2 PLL = PLLBASE + TMP I2CWrite SDA,SCL,ADDR1,[PLLHI,PLLLO,$8E] ' send command to PLL Serout LCDPIN, BAUDRATE,[12] ' Clear screen Serout LCDPIN, BAUDRATE,["PortB= ", #PORTB] ' Print PortB value (0-255) Pause 1000 GoTo MAIN




Bookmarks