<html>
<head>
<meta content="text/html; charset=iso-8859-2"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Zkuste CAN_ABOM a CAN_NART nastavit na
ENABLE.<br>
Neni sbernice defaultne v neklidovem stavu, treba prehozene H a L
nebo zkrat? Radic to detekuje a po nejakych stech cyklech se uvede
do neprovozniho stavu (ABOM resi aspon automatickou reinicializaci
po nejakem case klidu na sbernici)<br>
<br>
Dne 10.11.2016 v 13:38 tomas mainzer napsal(a):<br>
</div>
<blockquote
cite="mid:CAGQuSvBxcUizQxckdpW56CWR3b-jF55DB_-6H10NzQvib_u+kA@mail.gmail.com"
type="cite">
<div dir="ltr">Dobry den,
<div>nemate nekdo prosim funkcni priklad pro STM32F042 a can
bus?</div>
<div>Vychazim z prikladu pro STM32f072 - ake nedari se mi ani
odeslat CAN packet - uz jsem vyzkousel priklady (puvodne pro
STM32F072) pro SPL knihovny (to prekladam v embitz) i pro
CubeMX (to prekladam v Atollic TRUEstudiu) a nedokazu prijit
na to kde je zakopan pes.</div>
<div>Uvitam jakekoliv tipy. </div>
<div><br>
</div>
<div>Nize je relevantni vysek programu pro SPL (CAN je na pinech
PA11,PA12):</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div> GPIO_InitTypeDef GPIO_InitStructure;</div>
<div> NVIC_InitTypeDef NVIC_InitStructure;</div>
<div> CAN_InitTypeDef CAN_InitStructure;</div>
<div> CAN_FilterInitTypeDef CAN_FilterInitStructure;</div>
<div><br>
</div>
<div><br>
</div>
<div> /* CAN GPIOs configuration
**************************************************/</div>
<div><br>
</div>
<div> /* Enable GPIO clock */</div>
<div> //RCC_AHBPeriphClockCmd(CAN_GPIO_CLK, ENABLE);</div>
<div> RCC_AHBPeriphClockCmd(RCC_APB1Periph_CAN, ENABLE);</div>
<div> RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);</div>
<div><br>
</div>
<div> /* Connect CAN pins to AF7 */</div>
<div> GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_RX_SOURCE,
CAN_AF_PORT);</div>
<div> GPIO_PinAFConfig(CAN_GPIO_PORT, CAN_TX_SOURCE,
CAN_AF_PORT);</div>
<div><br>
</div>
<div> /* Configure CAN RX and TX pins */</div>
<div> GPIO_InitStructure.GPIO_Pin = CAN_RX_PIN | CAN_TX_PIN;</div>
<div> GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;</div>
<div> GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;</div>
<div> GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;</div>
<div> GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;</div>
<div> GPIO_Init(CAN_GPIO_PORT, &GPIO_InitStructure);</div>
<div><br>
</div>
<div> /* CAN NVIC configuration
**************************************************/</div>
<div> NVIC_InitStructure.NVIC_IRQChannel = CEC_CAN_IRQn;</div>
<div> NVIC_InitStructure.NVIC_IRQChannelPriority = 0;</div>
<div> NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;</div>
<div> NVIC_Init(&NVIC_InitStructure);</div>
<div><br>
</div>
<div> /* CAN configuration
********************************************************/</div>
<div> /* Enable CAN clock */</div>
<div> RCC_APB1PeriphClockCmd(CAN_CLK, ENABLE);</div>
<div><br>
</div>
<div> /* CAN register init */</div>
<div> CAN_DeInit(CANx);</div>
<div> CAN_StructInit(&CAN_InitStructure);</div>
<div><br>
</div>
<div> /* CAN cell init */</div>
<div> CAN_InitStructure.CAN_TTCM = DISABLE;</div>
<div> CAN_InitStructure.CAN_ABOM = DISABLE;</div>
<div> CAN_InitStructure.CAN_AWUM = DISABLE;</div>
<div> CAN_InitStructure.CAN_NART = DISABLE;</div>
<div> CAN_InitStructure.CAN_RFLM = DISABLE;//ENABLE;</div>
<div> CAN_InitStructure.CAN_TXFP = DISABLE;//ENABLE;</div>
<div> CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;</div>
<div> CAN_InitStructure.CAN_SJW = CAN_SJW_1tq;</div>
<div><br>
</div>
<div> /* CAN Baudrate = 1MBps (CAN clocked at 36 MHz) */</div>
<div> CAN_InitStructure.CAN_BS1 = CAN_BS1_9tq;</div>
<div> CAN_InitStructure.CAN_BS2 = CAN_BS2_8tq;</div>
<div> CAN_InitStructure.CAN_Prescaler = 2;</div>
<div> CAN_Init(CANx, &CAN_InitStructure);</div>
<div><br>
</div>
<div> /* CAN filter init "FIFO0" */</div>
<div> CAN_FilterInitStructure.CAN_FilterNumber = 0;</div>
<div> CAN_FilterInitStructure.CAN_FilterMode =
CAN_FilterMode_IdList;</div>
<div> CAN_FilterInitStructure.CAN_FilterScale =
CAN_FilterScale_32bit;</div>
<div> CAN_FilterInitStructure.CAN_FilterIdHigh = 0x6420;</div>
<div> CAN_FilterInitStructure.CAN_FilterIdLow = 0x2461;</div>
<div> CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;</div>
<div> CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;</div>
<div> CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;</div>
<div> CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;</div>
<div> CAN_FilterInit(&CAN_FilterInitStructure);</div>
<div><br>
</div>
<div> /* Transmit Structure preparation */</div>
<div> TxMessage.StdId = 0x321;</div>
<div> TxMessage.ExtId = 0x00;</div>
<div> TxMessage.RTR = CAN_RTR_DATA;</div>
<div> TxMessage.IDE = CAN_ID_STD;</div>
<div> TxMessage.DLC = 1;</div>
<div><br>
</div>
<div> /* Enable FIFO 0 full Interrupt */</div>
<div> //CAN_ITConfig(CANx, CAN_IT_FF0, ENABLE);</div>
<div> CAN_ITConfig(CANx, CAN_IT_FMP0, ENABLE);</div>
</div>
<div><br>
</div>
<div>...<br>
</div>
<div><br>
</div>
<div>
<div>TxMessage.Data[0] = (uint8_t)(tick);</div>
<div>CAN_Transmit(CANx, &TxMessage);</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Dekuji. TM.</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
HW-list mailing list - sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>