View previous topic :: View next topic |
Author |
Message |
Ttelmah
Joined: 11 Mar 2010 Posts: 19589
|
|
Posted: Mon Dec 13, 2021 11:29 am |
|
|
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: 9269 Location: Greensville,Ontario
|
|
Posted: Mon Dec 13, 2021 11:36 am |
|
|
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
|
|
Posted: Mon Dec 13, 2021 12:21 pm |
|
|
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
Thank you again, explaining my problem helps |
|
|
WalkOver
Joined: 14 May 2021 Posts: 24
|
|
Posted: Tue Dec 14, 2021 9:31 am |
|
|
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
Thank you everyone for your help. |
|
|
|