PDA

View Full Version : Pic18f2550 EEPROM Write



amenoera
- 17th September 2014, 10:43
Hi All ,

Can Anyone Please Clarify Why This Weird Output Occurs ?

Using PBP 2.60 , Pic18f2550 .

DEFINE OSC 48
@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
@ __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_512_2H
@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H & _MCLRE_OFF_3H
@ __CONFIG _CONFIG4L, _LVP_OFF_4L &_XINST_OFF_4L

USBBufferSizeMax con 8 ' maximum buffer size
USBBufferSizeTX con 8 ' input
USBBufferSizeRX con 8 ' output

' the USB buffer...
USBBuffer Var Byte[USBBufferSizeMax]
USBBufferCount Var Byte
i var Byte
' ************************************************** **********
' * main program loop - remember, you must keep the USB *
' * connection alive with a call to USBService every couple *
' * of milliseconds or so... *
' ************************************************** **********
usbinit ' initialise USB...
ProgramStart:

For i = 0 to 254 ;>>> Works Fine
write i,$3D ;>>>Works Fine
Next i ;>>>Works Fine

; But When Try This Without For-Next it Didnt Work :

i = $78
write 23,i ;>>> Weird Values At Location 23 , or No write .


gosub DoUSBIn
gosub DoUSBOut
goto ProgramStart

' ************************************************** **********
' * receive data from the USB bus *
' ************************************************** **********
DoUSBIn:
USBBufferCount = USBBufferSizeRX ' RX buffer size
USBService ' keep connection alive
USBIn 1, USBBuffer, USBBufferCount, DoUSBIn ' read data, if available
return

' ************************************************** **********
' * wait for USB interface to attach *
' ************************************************** **********
DoUSBOut:
USBBufferCount = USBBufferSizeTX ' TX buffer size
USBService ' keep connection alive
USBOut 1, USBBuffer, USBBufferCount, DoUSBOut ' if bus available, transmit data
return

amenoera
- 22nd September 2014, 10:44
No Reply Till Now , I Tried To Make It With at24c32 , Also With No Success !!!
* I Have A0&A1&A2&WP Wired To GND .

My Code :
AX VAR Byte
AX = $22

I2cWRITE PORTB.0,PORTB.1,$A0,$33,AX ; >>>Where Portb.0 is datapin , portb.1 clock pin , $A0 control , $33 memory address , AX my Data .

Nothing Written Or Wrong Values .

amenoera
- 23rd September 2014, 11:43
dears ,

please this drive me crazy , tried 16f84a & 18f2550 , no success at all, tried many examples , even in the installation of pbp folder all not working .

richard
- 24th September 2014, 00:04
I2cWRITE PORTB.0,PORTB.1,$A0,$33,AX ; >>>Where Portb.0 is datapin , portb.1 clock pin , $A0 control , $33 memory address , AX my Data .
did you read the pbp manual or the 24c32 data sheet ?

I2cWRITE PORTB.0,PORTB.1,commandbyte,addressword,[databyte];

amenoera
- 24th September 2014, 10:56
Dear Richard ,

thanks For Your Reply ,

But Let Me Explain Something , I read Both , And Tried everything With no Success .

Finally I Tried To Make It With Proton basic , Do you know , its working like a charm from first try with the A/M Example .

The Issue With Picbasic Itself .