Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SW Module HAL_CAN #11

Closed
pastorpflores opened this issue May 23, 2023 · 4 comments · Fixed by #29 or #63
Closed

SW Module HAL_CAN #11

pastorpflores opened this issue May 23, 2023 · 4 comments · Fixed by #29 or #63
Assignees
Labels
good first issue Good for newcomers

Comments

@pastorpflores
Copy link
Member

pastorpflores commented May 23, 2023

Module functionalities

  • Sends via CAN a premade payload & ID
  • Adds extended mode conf to msg
  • Reads incoming msgs
  • Set HW filters for incoming msgs
@RobertoAldea
Copy link
Member

#5 @mariuscrsn Transmission and receive functions, check name arguments and type of arguments (output should be pointers)

@RobertoAldea RobertoAldea moved this from 🆕 New to 🏗 In progress in EPC - Electronic Power Converter for battery cycling May 24, 2023
@pastorpflores
Copy link
Member Author

@RobertoAldea

Issues in CAN STM configuration.

Sending functions are now functional. Not reciving. In scope signals are OK, but some peripheral configuration is not correct.

@iuliaaan : Check testboard (needed jumpers configuration...)
@pastorpflores : Check STMF3 example from STM to check peripheral configuration -- @mariuscrsn : already done.
@pastorpflores : keep searching & keep calm :)

@mariuscrsn is going to help today. More updates tomorrow.

Moved to Week 22.

@mariuscrsn mariuscrsn self-assigned this May 30, 2023
@RobertoAldea
Copy link
Member

RobertoAldea commented May 31, 2023

To be able to receive messages in CAN is mandatory to configure an acceptance filter.
The way to accept all the incoming messages is configure it as below with this code:

  		sFilterConfig.FilterBank = 0;
  		sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
  		sFilterConfig.FilterScale = CAN_FILTERSCALE_16BIT; // High and Low are 2 different filters
  		sFilterConfig.FilterIdHigh = 0x000;
  		sFilterConfig.FilterIdLow = 0x000;
  		sFilterConfig.FilterMaskIdHigh=0x000; // Get all bits doesn´t matter the value
		sFilterConfig.FilterMaskIdLow=0x000;
  		sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
  		sFilterConfig.FilterActivation = ENABLE;
  		sFilterConfig.SlaveStartFilterBank = 14;
    	        res = HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);

The masks has a negative logic, if the set value is a 0 in the mask that bit it will get it no matter what is the value, however if a 1 is set, that bit will have to be the same as the one in the identifier specified.

@RobertoAldea RobertoAldea moved this from 🏗 In progress to 👀 In review in EPC - Electronic Power Converter for battery cycling May 31, 2023
@pastorpflores pastorpflores linked a pull request May 31, 2023 that will close this issue
@RobertoAldea
Copy link
Member

RobertoAldea commented May 31, 2023

#5 @mariuscrsn The final interface for the functions developed for HAL CAN are the following:

HAL_CAN_result_e HAL_CanInit();

HAL_CAN_result_e HAL_CanFilters(const uint16_t id, const uint16_t mask);

HAL_CAN_result_e HAL_CanTransmit (const uint32_t id, const uint8_t* data, const uint8_t size);

HAL_CAN_result_e HAL_CanReceive (uint32_t* id, uint8_t* data, uint8_t* size);

The function HAL_CanFilters implements a mask filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment