How-to configure the router to wake-up by CAN using C-code

4-Channel CAN Router with Data Logger
Post Reply
Grmblfx
Posts: 4
Joined: Wed 19. Feb 2020, 12:53

How-to configure the router to wake-up by CAN using C-code

Post by Grmblfx » Wed 19. Feb 2020, 13:18

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

User avatar
S.Schott
Hardware Development
Hardware Development
Posts: 32
Joined: Mon 4. Oct 2010, 16:50

Re: How-to configure the router to wake-up by CAN using C-code

Post by S.Schott » Wed 19. Feb 2020, 14:01

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.

Grmblfx
Posts: 4
Joined: Wed 19. Feb 2020, 12:53

Re: How-to configure the router to wake-up by CAN using C-code

Post by Grmblfx » Wed 19. Feb 2020, 15:22

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?

User avatar
P.Steil
Hardware Development
Hardware Development
Posts: 32
Joined: Fri 14. Jan 2011, 10:27

Re: How-to configure the router to wake-up by CAN using C-code

Post by P.Steil » Thu 20. Feb 2020, 07:46

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
--------------------------------------------
PEAK-System HW development Team
support@peak-system.com
phone: +49-6151-8173-20
fax: +49-6151-8173-29
--------------------------------------------

Grmblfx
Posts: 4
Joined: Wed 19. Feb 2020, 12:53

Re: How-to configure the router to wake-up by CAN using C-code

Post by Grmblfx » Thu 20. Feb 2020, 18:24

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

User avatar
S.Schott
Hardware Development
Hardware Development
Posts: 32
Joined: Mon 4. Oct 2010, 16:50

Re: How-to configure the router to wake-up by CAN using C-code

Post by S.Schott » Fri 21. Feb 2020, 10:55

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

Grmblfx
Posts: 4
Joined: Wed 19. Feb 2020, 12:53

Re: How-to configure the router to wake-up by CAN using C-code

Post by Grmblfx » Fri 21. Feb 2020, 16:38

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.
Attachments
main.wakeup.works.c
(10.93 KiB) Downloaded 2336 times
main.wakeup.broken.c
(10.93 KiB) Downloaded 2358 times

User avatar
P.Steil
Hardware Development
Hardware Development
Posts: 32
Joined: Fri 14. Jan 2011, 10:27

Re: How-to configure the router to wake-up by CAN using C-code

Post by P.Steil » Mon 24. Feb 2020, 14:43

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
--------------------------------------------
PEAK-System HW development Team
support@peak-system.com
phone: +49-6151-8173-20
fax: +49-6151-8173-29
--------------------------------------------

Post Reply