<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: lpc11c24 can problems in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591940#M29818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Wed Nov 19 07:37:52 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I had an issue with my CAN setup early on. Scope showed apparently good signals&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sometimes receive, Analyzer would never ack.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Turned out all those sync/propogation/phase1/phase2 and sync jump width in the Bosch spec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mapping to tseg1 and tseg2 in the LPC interface and the minus-one encoding in the LPC registers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;meant that although my actual bit rate was right, the 'segments' added up to one more than&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;they should. Hence progressive bit sample time shifting. And explained short messages&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with lots of 1-0-1 changes in the pattern were mostly ok, longer payloads/runs of 1 or 0 not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two (wrongly programmed) custom boards would probably be ok. You need to talk to a foreign&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;device (you analyser) to confirm spec complience.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the 1778 so the register name may be different and rearranged (don't have time to read the 11xxx manual.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I write my 'drivers' in M3 assembler. But at least the commentary, macros (#defines) in the following&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;snippet should help you double check you bit rate setup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
;-----------------------------------------------------------------------!
; Init CAN Module [2]!
;-----------------------------------------------------------------------!

;&amp;nbsp; P0.4&amp;nbsp; CAN 2 Rx !pu/d !hys !inv !filter fast slew !OD
;&amp;nbsp; P0.5&amp;nbsp; CAN 2 Tx !pu/d !hys !inv !filter fast slew !OD
;&amp;nbsp; P1.12 CAN Stby&amp;nbsp; pu&amp;nbsp;&amp;nbsp; !hys !inv !filter fast slew !OD output


P112= (1&amp;lt;&amp;lt;28)+(12&amp;lt;&amp;lt;20)+(1&amp;lt;&amp;lt;12)+0x01; P1.12[1] out/lo

Clk= 120000000; peripheral clock = 120MHz
;CBT=&amp;nbsp;&amp;nbsp;&amp;nbsp; 250000; can bit rate = 250Kbps
CBT=&amp;nbsp;&amp;nbsp; 1000000; can bit rate =&amp;nbsp;&amp;nbsp; 1Mbps
TQ=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24; nbr time quanta per bit

BPR= ((Clk/CBT)/TQ)-1; baud 250Kbps [24 quanta per bit]

; Sync+Prop+Phase1+Phase2 MUST EQUAL TQ; and all must be &amp;lt;= 8

Sync= 1; sync = 1 [Mandated by spec]
Prop= 7; propagation delay
Phase1= 8; pre&amp;nbsp; sample point
Phase2= 8; post sample point

TSeg1= (Prop+Phase1)-1; minus 1 encoding
TSeg2= (Phase2)-1; minus 1 encoding

SJW= (4)-1; max allowed (and &amp;lt;= min Phase1/2)
SS= 0; 0/1 single/triple sampling

Baud= (SS&amp;lt;&amp;lt;23)+(TSeg2&amp;lt;&amp;lt;20)+(TSeg1&amp;lt;&amp;lt;16)+(SJW&amp;lt;&amp;lt;14)+(BPR&amp;lt;&amp;lt;0)

;------------------------------------------------------------------------
fn InitCAN

push{lr}; save regs
movsr0, pCAN2; enable peripheral clock
blPowerOn;
adrr0, canPins; Assign pins
blPinSetup;

ldrr3, =canBase; setup the CAN Controller
movsr0, 1; disable during setup
strr0, [r3, canMode];

ldrr0, =Baud; CAN bus timing details
strr0, [r3, canTiming];

movsr0, 0; clear errors/disable interrupts
strr0, [r3, canIntEnable];
strr0, [r3, canGStatus];
ldrr1, [r3, canIntStatus]; reset any interrupt flags
movsr1, (1&amp;lt;&amp;lt;3)+(1&amp;lt;&amp;lt;2)+(1&amp;lt;&amp;lt;1); abort tx, release rx, clr overrun
strr1, [r3, canCmd];

; set IRQ handler
; enable Rx Irq

movsr0, 0; enable controller
strr0, [r3, canMode];

ldrr3, =filtBase; bypass acceptance filter
movsr0, 3; and start accepting messages
strr0, [r3, filtCtrl];

ldrr0, =P112; bring CAN transciever
blPioSetDir; out of standby

pop{pc}; return

fe InitCAN

;------------------------------------------------------------------------
canPins:;Port&amp;nbsp;&amp;nbsp;&amp;nbsp; Pin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp; Func&amp;nbsp; Flags
.word(0&amp;lt;&amp;lt;28)+(04&amp;lt;&amp;lt;20)+(2&amp;lt;&amp;lt;12)+(2&amp;lt;&amp;lt;8)+0x08; CAN
.word(1&amp;lt;&amp;lt;28)+(12&amp;lt;&amp;lt;20)+(1&amp;lt;&amp;lt;12)+(0&amp;lt;&amp;lt;8)+0x01, 0; GPIO

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 22:53:47 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T22:53:47Z</dc:date>
    <item>
      <title>lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591934#M29812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by gtt_rik on Mon Nov 17 07:38:59 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an issue with the ccan functionality on the LPC11c24 microcontroller on the lpcxpresso board.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems that it has been configured correctly to transmit but i cannot be sure. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After setting up, it correctly sends the can message, but instead of just doing it once, it keeps sending the message.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, it does not trigger the callback function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this because the message needs to be acknowledged by other nodes in the network?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A can-analyzer is available but it does not seem to work (termination?), but the message contents have been confirmed with an oscilloscope.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Added below are the source files&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Rik Freije&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Electrical Engineer power train&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Green Team Twente&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Main.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpastebin.com%2FuDfJ9VSw" rel="nofollow" target="_blank"&gt;http://pastebin.com/uDfJ9VSw&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ccanlib.c&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpastebin.com%2FpL4Fsm3Y" rel="nofollow" target="_blank"&gt;http://pastebin.com/pL4Fsm3Y&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ccanlib header&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fpastebin.com%2FVD2x9HxM" rel="nofollow" target="_blank"&gt;http://pastebin.com/VD2x9HxM&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591934#M29812</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591935#M29813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Mon Nov 17 08:05:19 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;A CAN transmission is not deemed sucessfull unless another node (any other node) ACKnowledges the packet frame.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The CAN controller will re-transmit at intervals indefinately until it gets an acknowlegement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your CAN analyser is most probably is LISTEN mode. I detects and displays all messages on the CAN bus, but&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DOESN'T acknowledge anything.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your setup is probably correct, you just need another active CAN node on the bus. Do you have two prototypes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You seem less than familliar with CAN operation. Try googling CAN BUS or see the Wikipedia page for CAN Bus.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS Double posting will not win you any friends.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591935#M29813</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591936#M29814</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Mon Nov 17 08:45:40 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: gtt_rik&lt;/STRONG&gt;&lt;BR /&gt;Is this because the message needs to be acknowledged by other nodes in the network?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, to avoid this just set DAR (Disable automatic retransmission) in CANCNTL register&amp;nbsp; :) &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591936#M29814</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591937#M29815</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by BoiOkkenGTT on Mon Nov 17 09:05:40 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello, i am working together with Rik on the same system.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: MikeSimmonds&lt;/STRONG&gt;&lt;BR /&gt;A CAN transmission is not deemed sucessfull unless another node (any other node) ACKnowledges the packet frame.&lt;BR /&gt;The CAN controller will re-transmit at intervals indefinately until it gets an acknowlegement.&lt;BR /&gt;&lt;BR /&gt;Your CAN analyser is most probably is LISTEN mode. I detects and displays all messages on the CAN bus, but&lt;BR /&gt;DOESN'T acknowledge anything.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is strange since we put the CAN analyzer explicitly in normal mode and the can analyzer does not detect or display anything. This is why i suspected the termination to be wrong, but after looking over both the documentation for the lpcxpresso board and the can analyzer, it seems to be terminated properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We also did not know that the hardware of the 11c24 defaults to automatic retransmission.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I will go over the settings again tommorow to verify that the can analyzer is actually set up correctly. BTW, the analyzer used is the one from microchip.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: MikeSimmonds&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Your setup is probably correct, you just need another active CAN node on the bus. Do you have two prototypes.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We do have more than one board, but using the analyzer is more convienient for quick debugging etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: R2D2&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: gtt_rik&lt;/STRONG&gt;&lt;BR /&gt;Is this because the message needs to be acknowledged by other nodes in the network?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;Yes, to avoid this just set DAR (Disable automatic retransmission) in CANCNTL register&amp;nbsp; :)&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ah, i will look over that option tommorow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you both very much.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Boi Okken&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Electrical Engineer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Drive train and secondary systems&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Green Team Twente&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591937#M29815</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:45Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591938#M29816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by BoiOkkenGTT on Wed Nov 19 04:19:30 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: BoiOkkenGTT&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;This is strange since we put the CAN analyzer explicitly in normal mode and the can analyzer does not detect or display anything. &lt;BR /&gt;...&lt;BR /&gt;I will go over the settings again tommorow to verify that the can analyzer is actually set up correctly. BTW, the analyzer used is the one from microchip.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After working on it yesterday and today, i think the problem indeed lies with the can bus analyzer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: BoiOkkenGTT&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;We do have more than one board, but using the analyzer is more convienient for quick debugging etc.&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We used a second board to receive messages from the first board, which works. Also confirmed with the oscilloscope that only one single message is send and no retransmission occurs.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think the topic can be closed, once again thank you for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yours sincerely,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Boi Okken&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Electrical Engineer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Drive train and secondary systems&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Green Team Twente&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591938#M29816</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591939#M29817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Wed Nov 19 05:32:21 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: BoiOkkenGTT&lt;/STRONG&gt;&lt;BR /&gt;Also confirmed with the oscilloscope that only one single message is send and no retransmission occurs.&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your oscilloscope can also show you if there's an ACK in the ACK slot of the frame...&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591939#M29817</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: lpc11c24 can problems</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591940#M29818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by MikeSimmonds on Wed Nov 19 07:37:52 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I had an issue with my CAN setup early on. Scope showed apparently good signals&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sometimes receive, Analyzer would never ack.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Turned out all those sync/propogation/phase1/phase2 and sync jump width in the Bosch spec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mapping to tseg1 and tseg2 in the LPC interface and the minus-one encoding in the LPC registers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;meant that although my actual bit rate was right, the 'segments' added up to one more than&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;they should. Hence progressive bit sample time shifting. And explained short messages&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;with lots of 1-0-1 changes in the pattern were mostly ok, longer payloads/runs of 1 or 0 not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Two (wrongly programmed) custom boards would probably be ok. You need to talk to a foreign&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;device (you analyser) to confirm spec complience.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use the 1778 so the register name may be different and rearranged (don't have time to read the 11xxx manual.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I write my 'drivers' in M3 assembler. But at least the commentary, macros (#defines) in the following&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;snippet should help you double check you bit rate setup.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HTH Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
;-----------------------------------------------------------------------!
; Init CAN Module [2]!
;-----------------------------------------------------------------------!

;&amp;nbsp; P0.4&amp;nbsp; CAN 2 Rx !pu/d !hys !inv !filter fast slew !OD
;&amp;nbsp; P0.5&amp;nbsp; CAN 2 Tx !pu/d !hys !inv !filter fast slew !OD
;&amp;nbsp; P1.12 CAN Stby&amp;nbsp; pu&amp;nbsp;&amp;nbsp; !hys !inv !filter fast slew !OD output


P112= (1&amp;lt;&amp;lt;28)+(12&amp;lt;&amp;lt;20)+(1&amp;lt;&amp;lt;12)+0x01; P1.12[1] out/lo

Clk= 120000000; peripheral clock = 120MHz
;CBT=&amp;nbsp;&amp;nbsp;&amp;nbsp; 250000; can bit rate = 250Kbps
CBT=&amp;nbsp;&amp;nbsp; 1000000; can bit rate =&amp;nbsp;&amp;nbsp; 1Mbps
TQ=&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 24; nbr time quanta per bit

BPR= ((Clk/CBT)/TQ)-1; baud 250Kbps [24 quanta per bit]

; Sync+Prop+Phase1+Phase2 MUST EQUAL TQ; and all must be &amp;lt;= 8

Sync= 1; sync = 1 [Mandated by spec]
Prop= 7; propagation delay
Phase1= 8; pre&amp;nbsp; sample point
Phase2= 8; post sample point

TSeg1= (Prop+Phase1)-1; minus 1 encoding
TSeg2= (Phase2)-1; minus 1 encoding

SJW= (4)-1; max allowed (and &amp;lt;= min Phase1/2)
SS= 0; 0/1 single/triple sampling

Baud= (SS&amp;lt;&amp;lt;23)+(TSeg2&amp;lt;&amp;lt;20)+(TSeg1&amp;lt;&amp;lt;16)+(SJW&amp;lt;&amp;lt;14)+(BPR&amp;lt;&amp;lt;0)

;------------------------------------------------------------------------
fn InitCAN

push{lr}; save regs
movsr0, pCAN2; enable peripheral clock
blPowerOn;
adrr0, canPins; Assign pins
blPinSetup;

ldrr3, =canBase; setup the CAN Controller
movsr0, 1; disable during setup
strr0, [r3, canMode];

ldrr0, =Baud; CAN bus timing details
strr0, [r3, canTiming];

movsr0, 0; clear errors/disable interrupts
strr0, [r3, canIntEnable];
strr0, [r3, canGStatus];
ldrr1, [r3, canIntStatus]; reset any interrupt flags
movsr1, (1&amp;lt;&amp;lt;3)+(1&amp;lt;&amp;lt;2)+(1&amp;lt;&amp;lt;1); abort tx, release rx, clr overrun
strr1, [r3, canCmd];

; set IRQ handler
; enable Rx Irq

movsr0, 0; enable controller
strr0, [r3, canMode];

ldrr3, =filtBase; bypass acceptance filter
movsr0, 3; and start accepting messages
strr0, [r3, filtCtrl];

ldrr0, =P112; bring CAN transciever
blPioSetDir; out of standby

pop{pc}; return

fe InitCAN

;------------------------------------------------------------------------
canPins:;Port&amp;nbsp;&amp;nbsp;&amp;nbsp; Pin&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Count&amp;nbsp;&amp;nbsp; Func&amp;nbsp; Flags
.word(0&amp;lt;&amp;lt;28)+(04&amp;lt;&amp;lt;20)+(2&amp;lt;&amp;lt;12)+(2&amp;lt;&amp;lt;8)+0x08; CAN
.word(1&amp;lt;&amp;lt;28)+(12&amp;lt;&amp;lt;20)+(1&amp;lt;&amp;lt;12)+(0&amp;lt;&amp;lt;8)+0x01, 0; GPIO

&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers, Mike&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 22:53:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/lpc11c24-can-problems/m-p/591940#M29818</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T22:53:47Z</dc:date>
    </item>
  </channel>
</rss>

