PDA

View Full Version : I2CWrite question



Qacer
- 3rd March 2006, 22:19
Hi all,

I have the following code:




DEFINE OSCCAL_1K 1 'The 12F675 has an internal 4MHz
'oscillator that can be calibrated
'internally. This sets the OSCCAL
'register for this device.

CMCON = 7 'CMCON deals with the comparator feature
ANSEL = 0 'ANSEL deals with the analog-digital
'converter. These two statements disables
'them in order to use the GPIO ports.

addr VAR BYTE
fmwrt1 VAR BYTE 'These variables represent the write
fmwrt2 VAR BYTE 'data bytes for the I2C device. Each data
fmwrt3 VAR BYTE 'byte holds a configuration bit that will
fmwrt4 VAR BYTE 'affect the function of the FM IC.
fmwrt5 VAR BYTE


addr = $C0 'The addr variable is assigned the hardware
'address for the FM IC. This address is
'specified in the datasheet.

fmwrt1 = %01101010
fmwrt2 = %10011000
fmwrt3 = %10111000
fmwrt4 = %00010100
fmwrt5 = %01000000

I2CWRITE GPIO.0, GPIO.1,addr,[fmwrt1,fmwrt2,fmwrt3,fmwrt4,fmwrt5], NOGO



END

NOGO: SOUND GPIO.4,[80,10,90,10,100,10,120,10]
GOTO NOGO




If I send this code to the PIC and just let it run via the programmer (PicKit 1 Starter), then if I put a speaker across GND and GPIO Port 4, I should hear a sound right? I'm assuming that the I2CWrite routine will give an error because I am not connecting the PIC to any I2C device.

Note: The speaker works because I tested it just using the SOUND routine and connecting it to GPIO and GND.

Thanks again!

:)