Skip to content

Commit b2a47fa

Browse files
authored
Merge pull request #59 from HamedJafarzadeh/master
Fix baudrate variable type | Fix Comm Reset | Fix Timer Issue
2 parents c7fb1de + 6dfc481 commit b2a47fa

5 files changed

Lines changed: 10 additions & 9 deletions

File tree

CANopenNode_STM32/CO_app_STM32.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,11 @@ canopen_app_process() {
215215

216216
if (reset_status == CO_RESET_COMM) {
217217
/* delete objects from memory */
218+
HAL_TIM_Base_Stop_IT(canopenNodeSTM32->timerHandle);
218219
CO_CANsetConfigurationMode((void*)canopenNodeSTM32);
219220
CO_delete(CO);
220221
log_printf("CANopenNode Reset Communication request\n");
221-
canopen_app_resetCommunication(); // Reset Communication routine
222+
canopen_app_init(canopenNodeSTM32); // Reset Communication routine
222223
} else if (reset_status == CO_RESET_APP) {
223224
log_printf("CANopenNode Device Reset\n");
224225
HAL_NVIC_SystemReset(); // Reset the STM32 Microcontroller

CANopenNode_STM32/CO_app_STM32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ typedef struct {
3131
* be the final NodeID, after calling canopen_app_init() you should check ActiveNodeID of CANopenNodeSTM32 structure for assigned Node ID.
3232
*/
3333
uint8_t activeNodeID; /* Assigned Node ID */
34-
uint8_t baudrate; /* This is the baudrate you've set in your CubeMX Configuration */
34+
uint16_t baudrate; /* This is the baudrate you've set in your CubeMX Configuration */
3535
TIM_HandleTypeDef*
3636
timerHandle; /*Pass in the timer that is going to be used for generating 1ms interrupt for tmrThread function,
3737
* please note that CANOpenSTM32 Library will override HAL_TIM_PeriodElapsedCallback function, if you also need this function in your codes, please take required steps

examples/stm32f0xx_can/CANOpenNode-NUCLEO-STM32F072.ioc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ CAN.ABOM=ENABLE
33
CAN.AWUM=ENABLE
44
CAN.BS1=CAN_BS1_13TQ
55
CAN.BS2=CAN_BS2_2TQ
6-
CAN.CalculateBaudRate=125000
7-
CAN.CalculateTimeBit=8000
8-
CAN.CalculateTimeQuantum=500.0
6+
CAN.CalculateBaudRate=1000000
7+
CAN.CalculateTimeBit=1000
8+
CAN.CalculateTimeQuantum=62.5
99
CAN.IPParameters=CalculateTimeQuantum,CalculateBaudRate,BS1,CalculateTimeBit,Prescaler,BS2,NART,ABOM,AWUM
1010
CAN.NART=ENABLE
11-
CAN.Prescaler=24
11+
CAN.Prescaler=3
1212
File.Version=6
1313
GPIO.groupedBy=Group By Peripherals
1414
KeepUserPlacement=false
@@ -125,7 +125,7 @@ ProjectManager.FreePins=false
125125
ProjectManager.HalAssertFull=false
126126
ProjectManager.HeapSize=0x200
127127
ProjectManager.KeepUserCode=true
128-
ProjectManager.LastFirmware=true
128+
ProjectManager.LastFirmware=false
129129
ProjectManager.LibraryCopy=1
130130
ProjectManager.MainLocation=Core/Src
131131
ProjectManager.NoMain=false

examples/stm32f0xx_can/Core/Src/can.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void MX_CAN_Init(void)
3838

3939
/* USER CODE END CAN_Init 1 */
4040
hcan.Instance = CAN;
41-
hcan.Init.Prescaler = 24;
41+
hcan.Init.Prescaler = 3;
4242
hcan.Init.Mode = CAN_MODE_NORMAL;
4343
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
4444
hcan.Init.TimeSeg1 = CAN_BS1_13TQ;

examples/stm32f0xx_can/Core/Src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int main(void)
114114
canOpenNodeSTM32.HWInitFunction = MX_CAN_Init;
115115
canOpenNodeSTM32.timerHandle = &htim17;
116116
canOpenNodeSTM32.desiredNodeID = 24;
117-
canOpenNodeSTM32.baudrate = 125;
117+
canOpenNodeSTM32.baudrate = 1000;
118118
canopen_app_init(&canOpenNodeSTM32);
119119
/* USER CODE END 2 */
120120

0 commit comments

Comments
 (0)