• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

SSPCON2 Problem

Status
Not open for further replies.

nicknamefrank

New Member
Hi all
I was wondering what is the purpose of this register?
This is the code that connects the PIC to the RTC timer and the loop below does not stop looping.

Code:
i2c_common_stop	macro
;input: 	none
;output:	none
;desc:		initiate stop condition on the bus

	banksel     SSPCON2
    bsf         SSPCON2,PEN
    btfsc       SSPCON2,PEN
    goto        $-1
	endm
 

Pommie

Well-Known Member
Most Helpful Member
SSPCON2 is used for Master I²C communication. If the above code does not stop looping then your initialisation is wrong.

Mike.
 
Well, shouldn't you be looking at the SSPIF flag for command completion? Seems that nearly every command in my MSSP module looks for the flag. So in BASIC syntax:

Code:
sub Stop
  SET SSPIF OFF   
  SET PEN ON  'Set Stop condition
 waitStop:
  IF SSPIF OFF THEN  'Check if operation complete
  goto waitStop
  end if
end sub
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top