PDA

View Full Version : 16f88 help



ccsparky
- 3rd July 2004, 16:39
Hello

I am attempting to use the DS1307 RTC and the 25LC640 spi eeprom with the 16f88 and have a few set up questions.
I went with the 16f88 because of the large code space availible.
I am using PICBasic Pro with MicroStudio Plus. I want to use the bootloader feature and have hooked up the 16f88 on my breadboard according to the diagram provided in the help file.
I am not sure how to set this chip up so any help in the area is greatly appriciated! First here is how I have my chips wired...

RA6 ----- Oscillator
RA7 ----- Oscillator
RB0 ----- eeprom CS pin
RB1 ----- DS1307 Data pin
RB2 ----- rs232 pin 11 (T1 IN)
RB3 ----- eeprom SCK pin
RB4 ----- DS1307 Clock pin
RB5 ----- rs232 pin 12 (R1 OUT)
RB6 ----- eeprom SI pin

I will be using other additional pins for digital i/o and do not need any anolog input. So I would like to turn off the anolog feature.
Here is what I have for the setup. Do I have mistakes or am I missing some items?

Define LOADER_USED 1
Define osc 4

Include "MODEDEFS.BAS"

ADCON1=6
TRISA = %00000000
TRISB = %00000100

'pins
CS VAR PORTB.0 'EEProm CS Line
DS_SDA var PORTB.1 'DS1307 Data Pin
SO con PORTB.2 'Serial Output
SCK VAR PORTB.3 'EEProm SCK Line
DS_SCL var PORTB.4 'DS1307 Clock Pin
SI con PORTB.5 'Serial Input
SI VAR PORTB.6 'EEProm SI Line

Any help or suggestions would be appriciated!

I have both the 4 and 20 mhz ocillators. Would it be better to go with the 20mhz ocillator?

Thank you
William

Melanie
- 3rd July 2004, 17:02
If you decide to use 20MHz then obviously change the DEFINE OSC statement. Whether you decide to go 20MHz depends if you can satisfy your application requirements whilst running at 4MHz. 4MHz parts are usually cheaper in production.

If you used a 24LC512, then it could have shared the I2C bus with the DS1307 and save yourself a heap of PIC pins in the process. As it is you've forgotten about the EEPROM's SO pin unless of course the EEPROM is going to be used as a WRITE ONLY device (ie datalogger application and you're going to crow-bar* it off the circuit-board to read-back)...

*Crow-Bar is a Bristish term for a chip-extractor/removal tool aka 'Wrecker-Bar' in the USA.

ccsparky
- 3rd July 2004, 17:13
Hello Melanie
Thank you for the help!

I had both the DS1307 and 25LC640 from a BX-24 (NetMedia) project but will look into the other chip.

I have been following the setup from "Experimenting with the PicBasic Pro Compiler" by Les Johnson and have the SO pin tied to the SI pin as indicated in the drawing.
I forgot Include 25XXXX.INC
Other than this how does the rest of the set up look?

Thanks again!

William

Melanie
- 3rd July 2004, 17:42
You've used 'con' instead of 'var' in a couple of your pin defines...

SO con PORTB.2 'Serial Output
SI con PORTB.5 'Serial Input

and you've duplicated the use of SI.

SI con PORTB.5 'Serial Input
SI VAR PORTB.6 'EEProm SI Line

Make your mind up about defining your Serial Comms pins...

RB2 ----- rs232 pin 11 (T1 IN) - Input or Output?
SO con PORTB.2 'Serial Output - here it looks like an Output...
TRISB = %00000100 - but here you've defined it as an input...

same for the other pin at RB5...

Hell, I'd hate to go out for dinner with you... "I'll have Lobster... nope I'll have the Steak... nope I'll have the Lobster..."

Look, you've chosen the pins to coincide with the Hardware USART (which is a good move as it gives you both Hardware and Serial software options to play with later in your code), so set the definitions accordingly (which you HAVE done CORRECTLY with TRISB)... and lose the confusing comments... and lose confusing definitions. What is 'SO'? Serial Output? Wrong pin if you're planning to use the USART Hardware and wrong for your setting of TRISB.2.

SerialReceive var PortB.2 ' RS232 Input
SerialTransmit var PortB.5 ' RS232 Output

Unless you're Forrest Gump it'll confuse the hell out of you otherwise.

Bet you now regret asking me for my comments...

*smiles*

Finally, don't forget RA5 is an INPUT ONLY pin if you're planning to use it for I/O and set TRISA appropriately.

ccsparky
- 3rd July 2004, 17:50
Ok, ok

But I like the steak and lobster combination :-)

I am not sorry I asked! I would have missed out on the laughter!
Hey, thanks for the help. I'll review what I have and think a little harder before I post!

Thanks

William

If you are ever in Nevada the lobster or the steak or the lobster is on me!