View previous topic :: View next topic |
Author |
Message |
HARSHAL KHAJONE
Joined: 16 Feb 2018 Posts: 7 Location: Pune
|
Problem with LIN communication |
Posted: Fri Feb 16, 2018 5:03 am |
|
|
hello everyone,
I'm going to learn LIN protocol for that i use uc PIC18f46k22 and LIN driver ic
MCP2021 and CCS PCH v5.008. I find LIN Bus sample example of PIC16F687/89/90 in CCS PCH v5.008 but i change this PIC16 uc to PIC18f46k22 in sample code by taking care of configuration bits and Register.
code was build in software successfully but does not work in proteus simulation(only get break field on DSO) and Hardware also
what i want to change further in code for PIC18f46k22
Please help me I'm tried lots of thing to get output
Thanks in advance |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Feb 16, 2018 6:25 am |
|
|
While I've never used LIN, I had a quick look at the CCS drivers, I do use the 46K22 and have the following comments.
1) It is highly improbable that Proteus will simulate a PIC18F46K22 and MCP2021, so don't waste your time.
2) Buy 2 of the PIC16F690 and bench test. The LIN drivers( master and slave) should work fine. Once this hardware configuration is 100% THEN proceed to the 46K22 PICs.
3) bench test the 46K22. 1st test should be a '1Hz LED' program. This will confirm your hardware(PIC + parts), compiler and programmer do function correctly. 2nd test will be a PC interface, aka serial using the HW UART of the PIC. This will confirm you CAN communicate to a PC. These days PCs only have USB ports, so you'll need a TTL<>USB module.
4) NOW you can copy the LIN drivers,name them 46K22_LIN_MASTER , 46K22_LIN_SLAVE and then edit this file. Do NOT edit the original CCS LIN drivers !! As you've discovered there are a LOT of registers that need to be renamed,so be careful, comment EVERY line you change or add !!
5) connect the 46K22 MASTER to the 690 SLAVE and test. Since the slave worked in #2 above, any failure is due to the 'MASTER' program. Edit as required to make it work.
6) Now that the 46K22 MASTER is working, edit the 46K22 SLAVE code, connect to 46K22 MASTER and test.
this series of steps should get your 46K22 LIN project working fairly fast.
You need to start with KNOWN working code AND hardware, and logically build upon them.
Jay |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 16, 2018 7:04 am |
|
|
You posted your code in a PM to me. You should post it here.
But anyway, one big problem is this line:
Code: | #FUSES XINST //Extended set extension and Indexed Addressing mode enabled |
CCS does not support this mode. Change the fuse to NOXINST. |
|
![](templates/subSilver/images/spacer.gif) |
HARSHAL KHAJONE
Joined: 16 Feb 2018 Posts: 7 Location: Pune
|
Problem with LIN communication |
Posted: Fri Feb 16, 2018 8:34 am |
|
|
temtronic Quote: |
thanks temtronic for your valuable advice
I'll try by giving your step by step procedure
[/list] |
|
|
![](templates/subSilver/images/spacer.gif) |
HARSHAL KHAJONE
Joined: 16 Feb 2018 Posts: 7 Location: Pune
|
|
Posted: Fri Feb 16, 2018 8:51 am |
|
|
PCM programmer wrote: | You posted your code in a PM to me. You should post it here.
But anyway, one big problem is this line:
Code: | #FUSES XINST //Extended set extension and Indexed Addressing mode enabled |
CCS does not support this mode. Change the fuse to NOXINST. |
thanks for reply...
I changed NOXINST fuse but output get as it is.
i seen at DSO Header frame of master send properly but slave does not respond to the master, I observed at slave side there is RC1IF does not get set. I also observed there is getc(); & while(!RC1IF) does not working...
please help me...
Thank you.. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Fri Feb 16, 2018 9:05 am |
|
|
obvious question but which HW UART are you using for the slave ? |
|
![](templates/subSilver/images/spacer.gif) |
HARSHAL KHAJONE
Joined: 16 Feb 2018 Posts: 7 Location: Pune
|
|
Posted: Fri Feb 16, 2018 9:11 am |
|
|
temtronic wrote: | obvious question but which HW UART are you using for the slave ? |
HW UART1 |
|
![](templates/subSilver/images/spacer.gif) |
|