CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

LIN bus built-in function source code ?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 11:29 am     Reply with quote

OK. Your master seeing the bytes it sends is inherent in the Linbus
design. Since it is a one wire bus, everything sent is also received.
That there is no reply implies the slave is not replying to the request
from the master. Tends to imply that something is wrong with what is
being sent. You need to triple check the data sheet for the slave device.
Baud rate correct?. Are you sure the wiring connection is correct?.
Are you sure the command you are sending triggers a reply?.
Now the standard code assumes the device(s) will reply. You would
have to add something like timeout support to avoid this hanging.
That the pump is responding at least partially, seems to say that most
of the connection is working.
Does the pump have a proper datasheet about it's protocol handling?.
Are you sure it supports the baud rate you are using?. It could just be
waking because it sees the correct 'wakeup' timing in the header, and
then not actually be accepting what is sent.
temtronic



Joined: 01 Jul 2010
Posts: 9081
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 11:36 am     Reply with quote

MAybe post a link to the device and it's datasheet.
I'm wondering if there's some 'startup/initialization of communications' that needs to be done before you really access the device ?
Similar to LCD modules , that need a minimum delay time before the micro accesses it ?
WalkOver



Joined: 14 May 2021
Posts: 24

View user's profile Send private message

PostPosted: Mon Dec 13, 2021 12:21 pm     Reply with quote

Hello Ttelmah,

I assume that what I sent is right because it seems right on the capture :



I just send PID with the U3P1 register and the uart module send Break Sync and PID.
On the top, you can see the Lin bus tied to +12V and below the Rx line and my dsPIC33CK MCU.

the data seems right with the correct baudrate. byte 2 is 0x79 = 121 = 12.1V

So the problem doesn't come from the pump but from my code or from the MCU.

While writing this post I added a 1ms delay between my Lin_send() function and an other function that write the number of bytes to receive to Parameter 3 (U3P3) ans the watermark interrupt to URXISEL register and now I received 9 bytes on the interrupt handler.

I will try to understand why Question

Thank you again, explaining my problem helps Laughing
WalkOver



Joined: 14 May 2021
Posts: 24

View user's profile Send private message

PostPosted: Tue Dec 14, 2021 9:31 am     Reply with quote

Hello,

I managed to get it working.

It just needed two things.

I have to wait the transmit shift register to be empty (TRMT).
So I no longer need to add delay after loading data in the UxP1 register.

The thing I don't understand is that I also need to read the UXRXREG register right after loading data in the UxP1 register ( outside the interrupt handler ) otherwise I only receive one byte in the interrupt handler regardless of the number of byte loaded on the UXP3 and URXISEL register.

With this little trick, everything is working as expected. I can control and read data with the lin bus configured as a Master without losing a single byte with all my application running in parallel.

I don't know why it didn't work with the built in CCS function but know I have non-blocking function so Im pretty happy Smile


Thank you everyone for your help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group