![]() |
Forum Index : Microcontroller and PC projects : I2C Problem - Lines being split
Author | Message | ||||
Bizzie Senior Member ![]() Joined: 06/07/2014 Location: AustraliaPosts: 192 |
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: AustraliaPosts: 6283 |
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 VK7JH MMedit |
||||
Bizzie Senior Member ![]() Joined: 06/07/2014 Location: AustraliaPosts: 192 |
Thanks Jim, As always simple when explained to you! Regards Rob Rob White |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |