The manual says do not use constants for address.
Though I tried the above but the result is the same.
While 1 : Wend - I just put this just like that to halt the code.
The manual says do not use constants for address.
Though I tried the above but the result is the same.
While 1 : Wend - I just put this just like that to halt the code.
Oh yeah, no Constants.
Then give it to him straight!
Have you tried clearing the LOC and Value variables at the beginning of each loop just in case? Start with a clean slate every time.
You're so close, I can smell it!Code:Main: Loc=0 Value=0 High Led : Pause 500: Low Led : PAUSE 500 I2CWRITE SDA,SCL,$36,[LOC],Fail1 I2CREAD SDA,SCL,$37,[VALUE] ,Fail2 PAUSE 25 DEBUG Value,13,10 PAUSE 250 DEBUG "Done....",13,10 WHILE 1 : WEND Goto Main Fail1: while 1: toggle portc.2 : pause 50 : wend goto main Fail2: WHILE 1 High Portc.2 : Pause 250 : Low PortC.2 : Pause 250 WEND
Or was that someone in the room?
Last edited by LinkMTech; - 27th July 2013 at 22:52.
Louie
Did the above, no luck.
Doesn't like it straight, giving it $37/$36 direct sends it to Fail1 routine. So write statement fails.
Funny thing is that when it goes to Fail1, though there should be no output of data, IT does output some of the data. This looks like half the data compared to when cycle runs normally.
The code only run once and then I reset the PIC to run it again, so though it won't make any effect resetting the values in the main loop, I still tried with no luck. I am losing hairs on my head because of this now.
Still Debugging after failing is strange. There is something else being introduced corrupting your instructions.
Use the Addr variables and see what happens when it free runs:
Going to church now, BBLCode:x VAR BYTE RD_Addr = $37 WR_Addr = $36 Main: High Led : Pause 500: Low Led : PAUSE 500 I2CWRITE SDA,SCL,WR_Addr,[LOC],Fail1 I2CREAD SDA,SCL,RD_Addr,[VALUE] ,Fail2 PAUSE 25 DEBUG Value,13,10 PAUSE 250 DEBUG "Done....",13,10 WHILE 1 : WEND Goto Main Fail1: FOR x = 0 TO 10 toggle portc.2 : pause 50 NEXT x goto main Fail2: FOR x = 0 TO 10 High Portc.2 : Pause 250 : Low PortC.2 : Pause 250 NEXT x GOTO Main
Louie
Is that Write only an initialisation?
Shouldn't it be outside the Main loop?
Robert
This is a Touch IC. So shouldn't you check the device ID once, then check at another address within the loop to detect a touch? (not sure of trigger yet)
I'm dense, won't WHILE 1: WEND loop endlessly?
Robert
Edit: I see it now; 1 to 7 keys max for I2C, triggers lines out.
Also, looking in datasheet if it says 400kHz max. I think you might have to run fast.
4.1.1 max 400kHz, so you should be able to run slower.
Last edited by Demon; - 28th July 2013 at 01:04.
Bookmarks