auto baudrate detection

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

auto baudrate detection

1,077 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ianLWD on Mon May 04 05:01:01 MST 2015
hi there!

For a project i want to edit the LPCopen canbus example program so it can automatically detect the baud rate. I have found a way how to do that.

http://www.can-cia.org/fileadmin/cia/files/icc/9/koppe.pdf

The microcontroller I'm using is the LPC11C24.
I want to set the cancontroller into silent mode so it will not generate error frames which will disrupt the canbus. I have no clue on how to set the registers. I know CMSIS uses LPC11xx.h to acces te registers. But I cannot find something simular for LPCopen.

So can anyone help me on how i can set the registers? In the userguide the registers are CANCNTL (0x4005 0000 bit 7 page 286 User Guide UM10398) And CANTEST (0x4005 0014 bit 3 page 291 User Guide UM10398).

With kind regards,

IanLWD
Labels (1)
0 Kudos
Reply
4 Replies

1,006 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ianLWD on Wed May 06 05:45:37 MST 2015
Hi R2D2,

I have started a project for a 6digits 14segments display. the display uses the canbus to link with a PLC.
I'm using the NXP_lpcxpresso_11C24_periph_Ccan_rom example. this example is from LPCopen.
I added some own code for the display.

Now I want to change some registers so I can program a automatic Baudrate detection.

atm I'm using LPCxpresso as compiler with default settings.


I hope this will make some sense.

thanks for helping me.

With kind regards,
ianlwd
0 Kudos
Reply

1,006 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed May 06 05:31:48 MST 2015

Quote: ianLWD
thanks for your reply, but it is still unclear what to do.



...because it's unclear what you are doing 

You don't describe your toolchain and you don't post your project (and if LPCOpen, the board library)

So I can just guess what you are doing

BTW: The correct name is:
 LPC_CAN[color=#f00]0[/color]->CNTL ...



Quote: ianLWD
'LPC_CAN' undeclared (first use in this function)"



... 'not declared' usually means that there is no correct declaration, that's this thing:

#define LPC_CAN0           ((LPC_CAN_TypeDef    *) LPC_CAN0_BASE)
0 Kudos
Reply

1,006 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by ianLWD on Wed May 06 04:16:24 MST 2015
Hello R2D2,

thanks for your reply, but it is still unclear what to do.

Where do I add the can struct?
I found the same struct in the LPC11xx.h
I allready tried to add the struct in the following header files:
  board.h
  ccand_11xx.h
  chip.h

it didnt work for me.

 
LPC_CAN->CNTL (1<<7);
after using this code,the error is : " 'LPC_CAN' undeclared (first use in this function)"

I hope you can help me with this.

with kind regards,
ianlwd
0 Kudos
Reply

1,006 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Mon May 04 07:51:55 MST 2015
There a missing a few things in LPCOpen 

Just add a CAN struct:

/*------------- CAN Controller (CAN) ----------------------------*/
/** @addtogroup LPC11xx_CAN LPC11xx Controller Area Network(CAN)
  @{
*/
typedef struct
{
  __IO uint32_t CNTL;/* 0x000 */
  __IO uint32_t STAT;
  __IO uint32_t EC;
  __IO uint32_t BT;
  __IO uint32_t INT;
  __IO uint32_t TEST;
  __IO uint32_t BRPE;
       uint32_t RESERVED0;
  __IO uint32_t IF1_CMDREQ;/* 0x020 */
  __IO uint32_t IF1_CMDMSK;
  __IO uint32_t IF1_MSK1;
  __IO uint32_t IF1_MSK2;
  __IO uint32_t IF1_ARB1;
  __IO uint32_t IF1_ARB2;
  __IO uint32_t IF1_MCTRL;
  __IO uint32_t IF1_DA1;
  __IO uint32_t IF1_DA2;
  __IO uint32_t IF1_DB1;
  __IO uint32_t IF1_DB2;
       uint32_t RESERVED1[13];
  __IO uint32_t IF2_CMDREQ;/* 0x080 */
  __IO uint32_t IF2_CMDMSK;
  __IO uint32_t IF2_MSK1;
  __IO uint32_t IF2_MSK2;
  __IO uint32_t IF2_ARB1;
  __IO uint32_t IF2_ARB2;
  __IO uint32_t IF2_MCTRL;
  __IO uint32_t IF2_DA1;
  __IO uint32_t IF2_DA2;
  __IO uint32_t IF2_DB1;
  __IO uint32_t IF2_DB2;
       uint32_t RESERVED2[21];
  __I  uint32_t TXREQ1;/* 0x100 */
  __I  uint32_t TXREQ2;
       uint32_t RESERVED3[6];
  __I  uint32_t ND1;/* 0x120 */
  __I  uint32_t ND2;
       uint32_t RESERVED4[6];
  __I  uint32_t IR1;/* 0x140 */
  __I  uint32_t IR2;
       uint32_t RESERVED5[6];
  __I  uint32_t MSGV1;/* 0x160 */
  __I  uint32_t MSGV2;
       uint32_t RESERVED6[6];
  __IO uint32_t CLKDIV;/* 0x180 */
} LPC_CAN_TypeDef;
/*@}*/ /* end of group LPC11xx_CAN */

#define LPC_CAN0           ((LPC_CAN_TypeDef    *) LPC_CAN0_BASE)


BTW: That's a known issue  :((

http://www.lpcware.com/content/forum/forgotten-can-register-struct-lpcxpresso-lpc11c24-lpcopen-v200a
0 Kudos
Reply