Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 11:12 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : I2C Problem - Lines being split

Author Message
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 02:15pm 20 Oct 2015
Copy link to clipboard 
Print this post

Hi All,

Why is there a problem in this simple test code?

Here is the code for the "Tramsmit" end :-


> list

I2C Open 100,100

Do
A = A + 1
InBuff$ = ">" + Str$(A) + ",11,12,13,14,15,16<"
I2C Write &H26,0,Len(inbuff$),InBuff$
Print InBuff$
Pause 1500
Loop

> ? mm.ver
4.05
> run
>1,11,12,13,14,15,16<
>2,11,12,13,14,15,16<
>3,11,12,13,14,15,16<
>4,11,12,13,14,15,16<
>5,11,12,13,14,15,16<
>6,11,12,13,14,15,16<
>


And for the receive :-

> list
' Bar graph display.

' Data from I2C

I2C SLAVE Open &H26,0,0,WriteD,ReadD


Do
WatchDog 1000
Loop

Sub BarGraf

End Sub

Sub ReadD
I2C Slave Read 70,InBuff$,Recd
Print Recd;"- ";InBuff$
BarGraf
End Sub

Sub WriteD

End Sub
> ? mm.ver
4.07
> run
2- >1
6- ,11,12
13- ,13,14,15,16<
2- >2
5- ,11,1
14- 2,13,14,15,16<
2- >3
6- ,11,12
13- ,13,14,15,16<
2- >4
5- ,11,1
14- 2,13,14,15,16<
2- >5
6- ,11,12
13- ,13,14,15,16<
2- >6
6- ,11,12
13- ,13,14,15,16<
2- >7
5- ,11,1
14- 2,13,14,15,16<
2- >8
6- ,11,12
13- ,13,14,15,16<
>


Note MM version info ie Maximite on transmit side and MicroMite on receive

Expected output :-
21- >8 ,11,12,13,14,15,16<

Anyone any ideas?

Rob

Rob White
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 03:37pm 20 Oct 2015
Copy link to clipboard 
Print this post

You appear to be suffering from the usual problem with serial comms.
The interrupt occurs as soon as the first character is received but it takes time for the rest of the message to arrive.
A simple 'PAUSE 400' at the beginning of your readD sub should solve the problem.
You may ahve to adjust the delay time to suit your data length.
Keep reducing the time until characters are lost the add a suitable time 'to be sure'.
The alternative is to store the incoming data into a buffer until you get to an end of data condition (character count or flag character etc).

Jim


Edit: It takes about 100uS for a character at 100k so if you are looking for up to 70 characters, try a delay of 10mS

Edited by TassyJim 2015-10-22
VK7JH
MMedit
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 05:39pm 20 Oct 2015
Copy link to clipboard 
Print this post

Thanks Jim,

As always simple when explained to you!

Regards

Rob

Rob White
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025