i2c interrupt test but not work

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
ta1dr
Registered User
Registered User
Posts: 15
Joined: Tue Aug 18, 2009 8:14 am
Location: istanbul TURKEY

i2c interrupt test but not work

Post by ta1dr » Wed Jul 27, 2011 9:33 am

I tried I2C interrupt for my CNC coordinate display but I could not
never trigger interrupt code normaly porta.0 is blink but porta.1 not led on

my code ;

Code: Select all

Device = 18F252
Clock =20

Const
   ipLow = 1,
   ipHigh = 2
Include "usart.bas"
//Include "ISRTimer.bas"
Include "Convert.bas"
Include "Utils.bas"
Dim i2cready,i2cadresrx,i2cadrestx,buf_rx_index,buf_tx_index,index As Byte
dim cnt as byte

Dim rx_buffer(64) As Byte
Dim tx_buffer(64) As Byte

Interrupt i2c(ipHigh) 'interrupt
   cnt=1
   porta.1=1
   PIR1.3=0
   
End Interrupt

SetAllDigital()
USART.SetBaudrate(br19200)
trisa.0=0
trisc.3=1
trisc.4=1
Clear(tx_buffer)
Clear(rx_buffer)
buf_rx_index=0
buf_tx_index=0
SSPCON1=%00101110
SSPCON2=0
SSPADD=54
SSPSTAT.7=1
SSPSTAT.6=0
i2cready=0
PIR1.3=0
PIe1.3=1
SSPCON1.4=1
rcon.7=1
intcon=%11000000
enable(i2c)
cnt=0
usart.write("All ok ",13,10)
While 1=1
      
      if cnt <> 0 then 
         usart.write(" ",dectostr(cnt),13,10)
      end if
      delayms (100)
      toggle (porta.0)
Wend
do you have any idea ?

thanks
Ahmet

RKP
Registered User
Registered User
Posts: 82
Joined: Mon Oct 22, 2007 3:14 pm
Location: Maryland

Post by RKP » Wed Jul 27, 2011 2:42 pm

Ahmet,

Try adding trisa.1=0 to your port set up code.

Ports default to inputs so you need to set up for an output to drive the LED.

Keith

ta1dr
Registered User
Registered User
Posts: 15
Joined: Tue Aug 18, 2009 8:14 am
Location: istanbul TURKEY

Post by ta1dr » Thu Jul 28, 2011 11:53 am

Thanks Keith
I think My brain needs to vitamin B12 :wink:

Post Reply