[Home]PIC 16F819 IIC/Serial Demo With Debug Of SSPSTAT

HomePage | PIC 16F819 IIC | RecentChanges | Preferences | My Website home page

Showing revision 6
This page discusses a demo that uses the IIC module on the PIC16F819.

Connect an RS232 via a resistor to a PIC16F819, with SDA and SCL pulled up and you can explore IIC.

Connect other IIC 7 bit devices and send and receive bytes from them.

It is possible to get the chip to talk to itself.

http://www.dougrice.plus.com/dev/iic001/iicrs001.ASM

; Uses PIC16F819
;
; Pull up SDA and SCL pins with 4k7 resistors,
;
; SERIAL PORT CONTROL:
;
;	PORT A0 is Serial input
;	PORT A0 is serial output
;
;	usb gmus-03 USB Serial Adapter
;
;	TX  D9 Pin 3 -[4k7]----+-----PA0
;	RX  D9 Pin 2 ----------/
;
;	GND D9 Pin 5 ---------------- 0V
;
 
;
; Serial Commands:-
;
;   ; w,p,r,g,f,a
;
;
; File Regiters
;	<CR>wAADD;		write DD to register AA
;	<CR>rAA;  		read AA and output to serial port
;
; EEPROM
;	<CR>pAADD;		write DD to EEPROM register AA
;	<CR>gAA;  		read EEPROM register AA and output to serial port
;
; PRIPHERALS
;
; IIC master commands to set to slave and master. 
;    Master is done by code. EEPROM
;
;	<CR>iAA;	IIC  init set Addr = AA
;
;	<CR><AA;	IIC START , ADDR , set lsb for R/W
;	<CR>>;		IIC STOP
;	<CR>/DD;	IIC master writeByte
;	<CR>?;	IIC master readByte & ACK.   If you get ~, SCL is being held low and read has timed out.
;	<CR>~;	IIC master readByte & NACK.  If you get ~, SCL is being held low and read has timed out.
;

Slave i2c code in C for the PIC16F886

I brought the Microchip Serial Analyser that has two boards with PIC16F886 chips.

I can connect this to the Raspberry Pi using a level shifter.

http://www.dougrice.plus.com/dev/iic001/test16f886.c

This seems to work, but the i2cdump gets read errors

http://www.dougrice.plus.com/dev/iic001/test16f886.c

Code for the Raspberry Pi. The PIC16F886 has a slave address 0f 0x08 or SSPADD = 0x10;

http://www.dougrice.plus.com/dev/iic001/rppic.c

This sends a byte with lights the LEDs and reads a counter that increments for each read to check if it is working.


HomePage | PIC 16F819 IIC | RecentChanges | Preferences | My Website home page
This page is read-only | View other revisions | View current revision
Edited March 2, 2021 9:57 pm by dougrice.plus.com
Search: