Hey welcome here
Configurations fuses are some of the PIC settings which may screw a design pretty quick. One of the most important is the Oscilattor setting. By default, PBP use XT mode, this is good enough for crystal ~4Mhz, you're using 20MHz so you need to change the OSC mode, in your case you select HS mode. Refer to section 2 of your datasheet.
There's several way to do it, but we suggest you to place the settings in your code, so you don't need to change it all the time before you program your PIC.
Short tutorial about that bellow... post 1-5 cover most thing you have to know.
http://www.picbasic.co.uk/forum/showthread.php?t=543
I'll suggest you to paste the following lines in your code.
Code:
asm
__CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOREN_ON_2L & _BORV_3_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _PBADEN_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_ON_3H & _CCP2MX_PORTC_3H
__CONFIG _CONFIG4L, _DEBUG_OFF_4L & _XINST_OFF_4L & _LVP_OFF_4L & _STVREN_ON_4L
endasm
Definitions of the above are in your datasheet section 23.1
once you have it and change your
Code:
DACAddressByte con %01001000
to
Code:
DACAddressByte con %10010000
it will produce this SCL signal
<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2469&stc=1&d=120729308 0">
and
<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=2468&stc=1&d=120729303 5">
I2CWRITE send the ControlByte first, then the address.. it's the usual naming convention for EEPROM, in your case they named it another way to better fit with their own convention... but the sequence must be the same as in your datasheet...so the way you did.
Bookmarks