Page 1 of 1
How-to configure the router to wake-up by CAN using C-code
Posted: Wed 19. Feb 2020, 13:18
by Grmblfx
Hi all,
I am looking for configuration help/code snippets to enable the PCAN-Router Pro to wake-up by CAN using the C-API.
Putting the router to sleep works with this code
CAN_SetTransceiverMode(CAN_BUS1, CAN_TRANSCEIVER_MODE_WAKEUP);
CAN_SetTransceiverMode(CAN_BUS2, CAN_TRANSCEIVER_MODE_WAKEUP);
CAN_SetTransceiverMode(CAN_BUS3, CAN_TRANSCEIVER_MODE_WAKEUP);
CAN_SetTransceiverMode(CAN_BUS4, CAN_TRANSCEIVER_MODE_WAKEUP);
HW_SwitchOFF();
However, If I re-start sending frames on any CAN bus the router stays powered off.
My router is equipped with CAN-HS-1041 transceiver which ought to be wake-up capable.
Does anyone know how to achieve this?
Thanks and greets,
Christian
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Wed 19. Feb 2020, 14:01
by S.Schott
Hello.
I think the command
CAN_TRANSCEIVER_MODE_WAKEUP
is rather made for low speed high voltage transceivers (like TH8056, AU5790).
Try
CAN_TRANSCEIVER_MODE_POWERDOWN
or
CAN_TRANSCEIVER_MODE_STANDBY
instead.
See can.h for some help on this.
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Wed 19. Feb 2020, 15:22
by Grmblfx
Hello S.Schott, Thanks for your reply.
I tried both settings (_MODE_POWERDOWN and _MODE_STANDBY) without success.
Are those the only settings I need to take care of?
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Thu 20. Feb 2020, 07:46
by P.Steil
hello,
try the code example "5_RTC" to check if this will work. Otherwise please tell us your serno of the module so
we will check this in our lab too. Do not forget to remove all conditions which will keep the router running
e.g. the external wake input.
regards
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Thu 20. Feb 2020, 18:24
by Grmblfx
The code example "5_RTC" is working and router is correctly waking-up by alarm or CAN input.
However, if I strip down the example to not configure RTC (uncommenting call to main_checkRTC()), neither putting the system to sleep does work (LEDs still on) nor waking it up again.
Seems the router is hanging which is especially of concern for in-vehicle application, because we won't be able to easily power-cycle the box for a reset.
Can you confirm my observations?
My workaround will be now to configure RTC but not using it.
Greets
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Fri 21. Feb 2020, 10:55
by S.Schott
Hi.
we're looking into it monday morning, as my colleague P.Steil is not here for the rest of the day.
Meanwhile make sure that
- there are -really- 1041's equipped on the resp. ports,
- CAN termination is on,
- you do not have CAN traffic while going to sleep
(having already down the uC, but not yet the pwr supply makes a zombie),
Info: Any CAN msg. to the 1041 will wake the pwr supply only, not the uC!
The supply in turn starts the uC and this initializes the whole device.
- that after HW_off() there is 3 sec. silence on all buses (discharging int. capacitors to reach a deep power off),
Hint: Inserting a CF card as a power consumer makes discharging a little faster.
Your current code snippet (RTC with mod's) would also be useful.
info(at)peak-system.com
Greetings
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Fri 21. Feb 2020, 16:38
by Grmblfx
I attached the code I am using. Slightly modified from original example. On my side the effect is reproducible (for broken.c I use the command 0x55 AA 02).
My setup meets all conditions mentioned. I also disconnect PCAN-USB.
Router Label: IPEH-002212 00857
Lib used: libPCAN-Router-ProGNU1.0.1ys.a
Thanks for your help.
Re: How-to configure the router to wake-up by CAN using C-code
Posted: Mon 24. Feb 2020, 14:43
by P.Steil
Hello,
see comment about line 82:
// check the alarm flag. If set, the module was switched ON by the RTC. If cleared, the module
// was powered UP by another event like remote wake up. The flag is cleared by the read process,
// so this check can be done only once. If needed you have to save the state to a global variable.
// Reading the alarm flag is necessary to move into power OFF by firmware. Otherwise the RTC will clamp
// the module in the powered state.
Try the following to put your module into a defined state:
> Clear the RTC alarmflag once (by reading it) due to behavior described above.
The flag might force the module in powered state.
> Call
RTC_WriteAlarm ( NULL, RTC_ALARM_OFF);
once to disable any pending RTC alarm (single or repeated). Clear alarm flag after that again.
After that the module should be in a state were the RTC should not influence again.
Regards
Philipp