Hi all ,
I am using stm32f103 with chibios v20,
I have modified can example to communicate with can radar, but i have problem in received packet .
when i have received a msg more than three packet the first three packet is OK and others sequence become wrong .?
any suggestion ?
best regards,
asd
can reseved problem Topic is solved
Moderators: RoccoMarco, barthess
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: can reseved problem
Hard to tell without looking at the actual traffic, most of the work is done by the peripheral in HW, the driver itself is very thin.
Few questions:
- Are you emptying the RX queues when you get a CAN event? you need to read until it is empty.
- Do you get CAN errors?
Giovanni
Few questions:
- Are you emptying the RX queues when you get a CAN event? you need to read until it is empty.
- Do you get CAN errors?
Giovanni
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: can reseved problem
Giovanni wrote:Hard to tell without looking at the actual traffic, most of the work is done by the peripheral in HW, the driver itself is very thin.
Few questions:
- Are you emptying the RX queues when you get a CAN event? you need to read until it is empty.
- Do you get CAN errors?
Giovanni
I am using this received msg
Code: Select all
/*
* Receiver thread.
*/
static THD_WORKING_AREA(can_rx_wa, 256);
static THD_FUNCTION(can_rx, p) {
event_listener_t el;
CANRxFrame rxmsg;
(void)p;
chRegSetThreadName("receiver");
chEvtRegister(&CAND1.rxfull_event, &el, 0);
while (true) {
if (chEvtWaitAnyTimeout(ALL_EVENTS, TIME_MS2I(100)) == 0)
continue;
while (canReceive(&CAND1, CAN_ANY_MAILBOX, &rxmsg, TIME_IMMEDIATE) == MSG_OK) {
/* Process message.*/
chprintf(chp,"EID %x",rxmsg);
palTogglePad(IOPORT3, GPIOC_LED);
}
}
chEvtUnregister(&CAND1.rxfull_event, &el);
}
The can packet is(500packet)Sequences (16us time between packet)
I think the time of reading is slowly ,
stm32f103 speed is 72MHz
can speed 1000K
but i don't know how to read faster?
and how can i set can callback function?
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: can reseved problem Topic is solved
Try removing the chprintf(), that is slowing down the loop for sure because it is bound by the serial port speed.
Giovanni
Giovanni
Re: can reseved problem
Giovanni wrote:Try removing the chprintf(), that is slowing down the loop for sure because it is bound by the serial port speed.
Giovanni
thanks for replay :
i will test it,
if I set CAN_ENFORCE_USE_CALLBACKS TRUE, can i have faster speed?
and how can i use callback function?
- Giovanni
- Site Admin
- Posts: 14455
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: can reseved problem
If what you want is to really print the incoming packets, you have to first do the math: Is that theoretically possible. To me it looks as if you are running out of time to print the packet summary with the first packet.asdasdasd wrote:i will test it,
if I set CAN_ENFORCE_USE_CALLBACKS TRUE, can i have faster speed?
You are printing 12 characters per message. If you send them at 9600 baud, that's about 1ms per character or 12 ms for the whole packet dump. With packets coming in every 16 us, that is about 1000x too slow..... You might be running at 38400 or 115200, but still that would be about 300 or 100 times too slow.
The USB should be able to handle it, but then your PC might be telling the USB device: "please hold off a moment" and then things go wrong.
Who is online
Users browsing this forum: No registered users and 30 guests