Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/i2c_eeprom.asm @ 53:263348f83485
1.70 cleaning the code
author | heinrichsweikamp |
---|---|
date | Sat, 31 Jul 2010 10:25:59 +0200 |
parents | da553e5c7a90 |
children | 31fa973a70fd |
comparison
equal
deleted
inserted
replaced
51:ceeeb5e49348 | 53:263348f83485 |
---|---|
331 movlw d'8' ; 400kHz I2C clock @ 16MHz Fcy | 331 movlw d'8' ; 400kHz I2C clock @ 16MHz Fcy |
332 movwf SSPADD | 332 movwf SSPADD |
333 bcf LED_red | 333 bcf LED_red |
334 ostc_debug 'O' ; Sends debug-information to screen if debugmode active | 334 ostc_debug 'O' ; Sends debug-information to screen if debugmode active |
335 return | 335 return |
336 I2C_TX: | 336 |
337 movwf i2c_temp2 ; Data byte | 337 ;I2C_TX: |
338 bsf SSPCON2,SEN ; Start condition | 338 ; movwf i2c_temp2 ; Data byte |
339 rcall WaitMSSP | 339 ; bsf SSPCON2,SEN ; Start condition |
340 movlw b'10010000' ; Bit0=0: WRITE, Bit0=1: READ | 340 ; rcall WaitMSSP |
341 movwf SSPBUF ; control byte | 341 ; movlw b'10010000' ; Bit0=0: WRITE, Bit0=1: READ |
342 rcall WaitMSSP | 342 ; movwf SSPBUF ; control byte |
343 rcall I2C_WaitforACK | 343 ; rcall WaitMSSP |
344 movff i2c_temp2, SSPBUF ; Data Byte | 344 ; rcall I2C_WaitforACK |
345 rcall WaitMSSP | 345 ; movff i2c_temp2, SSPBUF ; Data Byte |
346 rcall I2C_WaitforACK | 346 ; rcall WaitMSSP |
347 bsf SSPCON2,PEN ; Stop condition | 347 ; rcall I2C_WaitforACK |
348 rcall WaitMSSP | 348 ; bsf SSPCON2,PEN ; Stop condition |
349 return | 349 ; rcall WaitMSSP |
350 I2C_RX: | 350 ; return |
351 bcf PIR1,SSPIF | 351 ;I2C_RX: |
352 bsf SSPCON2,SEN ; Start condition | 352 ; bcf PIR1,SSPIF |
353 rcall WaitMSSP | 353 ; bsf SSPCON2,SEN ; Start condition |
354 movlw b'10010001' ; Bit0=0: WRITE, Bit0=1: READ | 354 ; rcall WaitMSSP |
355 movwf SSPBUF ; control byte | 355 ; movlw b'10010001' ; Bit0=0: WRITE, Bit0=1: READ |
356 rcall WaitMSSP | 356 ; movwf SSPBUF ; control byte |
357 rcall I2C_WaitforACK | 357 ; rcall WaitMSSP |
358 bsf SSPCON2, RCEN ; Enable recieve mode | 358 ; rcall I2C_WaitforACK |
359 rcall WaitMSSP | 359 ; bsf SSPCON2, RCEN ; Enable recieve mode |
360 movff SSPBUF,i2c_temp2 ; Data Byte | 360 ; rcall WaitMSSP |
361 bsf SSPCON2,ACKEN ; Master acknowlegde | 361 ; movff SSPBUF,i2c_temp2 ; Data Byte |
362 rcall WaitMSSP | 362 ; bsf SSPCON2,ACKEN ; Master acknowlegde |
363 bsf SSPCON2,PEN ; Stop condition | 363 ; rcall WaitMSSP |
364 rcall WaitMSSP | 364 ; bsf SSPCON2,PEN ; Stop condition |
365 return | 365 ; rcall WaitMSSP |
366 ; return |