cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Can-Bus Problem

doganayserhatt
Associate II
Posted on October 09, 2015 at 22:37

The original post was too long to process during our migration. Please click on the attachment to read the original post.
8 REPLIES 8
jpeacock
Associate III
Posted on October 09, 2015 at 22:49

Look at the two CAN_ESR registers to determine the error.  Do you have twisted pair between both nodes, and 120 ohm termination at each end?

  Jack Peacock

doganayserhatt
Associate II
Posted on October 09, 2015 at 22:59

First, thank you peacock.jack.003 for fast reply. Yep. I used  120 ohm resistor between can_H and can_L. In addition, USART6 can't run. No data doesn't appear. I use 2 x MCP2551 for Can1 and Can2 node. 

Posted on October 10, 2015 at 00:36

You'd need to have code to associate the USART6 with the STDIO functionality.

//******************************************************************************
// Hosting of stdio functionality through USART6
//******************************************************************************
#include <
rt_misc.h
>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
while(USART_GetFlagStatus(USART6, USART_FLAG_TXE) == RESET);
USART_SendData(USART6, ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
while(USART_GetFlagStatus(USART6, USART_FLAG_RXNE) == RESET);
ch = USART_ReceiveData(USART6);
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
while(USART_GetFlagStatus(USART6, USART_FLAG_TXE) == RESET);
USART_SendData(USART6, ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
doganayserhatt
Associate II
Posted on October 10, 2015 at 10:03

Thank you clive1, How do I associate this code with STDIO functionatily? Where do I add this code?

Posted on October 10, 2015 at 16:38

Where do I add this code?

Anywhere in your project. The system has no knowledge of how the data gets to the serial port unless you provide a route, in the manner provided here.

Please review Keil documentation for more background

http://www.keil.com/support/man/docs/gsac/gsac_retargetcortex.htm

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
doganayserhatt
Associate II
Posted on October 10, 2015 at 20:16

Thanks clive1. I will read that one.  I added that code block in the main program. But, This code can't work still. I used USART2, When i push reset button, meaningless character view in my serialport Program. I show you my schematic.

Schematic diagram : http://i57.tinypic.com/x0ra5j.jpg

Posted on October 11, 2015 at 02:55

Make sure HSE_VALUE is correctly define as 8000000 in you project (often stm32f4xx_conf.h) and the PLL settings assume an 8 MHz source.

Get you serial port output working so you have some chance of debugging/diagnosing your issues.

Circuit does not appear unreasonable.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
doganayserhatt
Associate II
Posted on October 11, 2015 at 09:58

I defined HSE_VALUE=8000000 in the Options for target-> C/C++. But it can't work. I will try with logic analyzer. I ordered it. I will share result here. Thanks clive1..