Wake Up from CAN_BUS
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Wake Up from CAN_BUS
Hi!
I need help)
I have Pic 18f2580 and MCP2551 connected to internal CAN-BUS.
I tried wake PIC up by RXINT, but it doesn't work.
How can I wake PIC up by activity in CAN-BUS?
I need help)
I have Pic 18f2580 and MCP2551 connected to internal CAN-BUS.
I tried wake PIC up by RXINT, but it doesn't work.
How can I wake PIC up by activity in CAN-BUS?
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Wake Up from CAN_BUS
Have you configured the CAN module to wake up on RX messages?Barmaley_GMN wrote: I tried wake PIC up by RXINT, but it doesn't work.
How can I wake PIC up by activity in CAN-BUS?
you need to post your minimal Flowchart that shows your configuration of the CAN module.
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
No. I just set the timer to RXINT and set Sleep()
I don't know if the macro TMR RXINT set configuration bit for wake up by activity on RX can-bus or it makes it for UART RX.
As I see, I need to set REQOP2:REQOP0 = 001 and WAKIF = 1. That's it?
I don't know if the macro TMR RXINT set configuration bit for wake up by activity on RX can-bus or it makes it for UART RX.
As I see, I need to set REQOP2:REQOP0 = 001 and WAKIF = 1. That's it?
- QMESAR
- Valued Contributor
- Posts: 1287
- Joined: Sun Oct 05, 2014 3:20 pm
- Location: Russia
- Has thanked: 384 times
- Been thanked: 614 times
- Contact:
Re: Wake Up from CAN_BUS
HiBarmaley_GMN wrote:No. I just set the timer to RXINT and set Sleep()
I don't know if the macro TMR RXINT set configuration bit for wake up by activity on RX can-bus or it makes it for UART RX.
As I see, I need to set REQOP2:REQOP0 = 001 and WAKIF = 1. That's it?
with out seeing your Flowchart and configuration settings it is hard to help ,
According to the device datasheet in my understanding is that you have to configure a CAN wakup interrupt which will be triggered when there is a message(activity) on the bus and the device is in sleep mode,
I do not think "That's it" as mentionedAs I see, I need to set REQOP2:REQOP0 = 001 and WAKIF = 1. That's it?
- Attachments
-
- 1.JPG (44.75 KiB) Viewed 9941 times
https://www.flowcodexchange.com/
Regards QMESAR
Regards QMESAR
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
Code: Select all
cr_bit(cancon, REQOP2);
cr_bit(cancon, REQOP1);
st_bit(cancon, REQOP0);
st_bit(pie3, WAKIE);
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Wake Up from CAN_BUS
Hello,
I may be wrong on this but it looks like you just need to use this C code to enable the wake from sleep and reset the interrupt flag.
I may be wrong on this but it looks like you just need to use this C code to enable the wake from sleep and reset the interrupt flag.
Code: Select all
cr_bit(pir3, WAKIF) //Clear interrupt flag if set - re-arm interrupt
st_bit(pie3, WAKIE); //Enable interrupt
st_bit(intcon, PEIE); //Enable Peripheral Interrupts
st_bit(intcon, GIE); //Enable Global Interrupts
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
There is mistake
it is read only bit.
And I haven't managed to make interrupt on CAN-BUS.
It stops transmit, but doesn't wake up the chip.
Now I think the problem is in the another interrupt (I'm using 2 interrupts in one program) When the first (by timer) is run - the second(by wake up) is off. Then the first stop the second run. And the second doesn't work.
Code: Select all
cr_bit(pir3, WAKIF) //Clear interrupt flag if set - re-arm interrupt
And I haven't managed to make interrupt on CAN-BUS.
It stops transmit, but doesn't wake up the chip.
Now I think the problem is in the another interrupt (I'm using 2 interrupts in one program) When the first (by timer) is run - the second(by wake up) is off. Then the first stop the second run. And the second doesn't work.
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
I have managed with wake up. But I used only one interrupt (by CAN activity). Now I have additional problems: after waking up it doesn't go sleep in next cycles.
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
Code: Select all
clear_bit(pir3, WAKIF); // clear interrupt
Interrupt
Enable code
Code: Select all
intcon.GIE = 1; // Enable global interrupts
intcon.PEIE = 1; // Enable peripheral interrupts
st_bit(cancon, REQOP0);
cr_bit(cancon, REQOP1);
cr_bit(cancon, REQOP2);
st_bit(pie3, WAKIE); //Enable interrupt CAN
Code: Select all
if (pir3 & (1 << WAKIF))
{
FCM_%n(); // call selected macro
clear_bit(pir3, WAKIF); // clear interrupt
}
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
I need help!
Code for Pic18f2580 doesn't work with 18f25K80
I see error in text box
What can I do?
Code for Pic18f2580 doesn't work with 18f25K80
I see error in text box
Code: Select all
DRL+V7-2.c(6768:23): error: unknown identifier 'REQOP0'
DRL+V7-2.c(6768:23): error: invalid operand 'REQOP0'
DRL+V7-2.c(6768:18): error: failed to generate expression
DRL+V7-2.c(6768:18): error: invalid operand '<<'
DRL+V7-2.c(6768:12): error: failed to generate expression
DRL+V7-2.c(6769:24): error: unknown identifier 'REQOP1'
DRL+V7-2.c(6769:24): error: invalid operand 'REQOP1'
DRL+V7-2.c(6769:19): error: failed to generate expression
DRL+V7-2.c(6769:15): error: invalid operand '~(1 << ( REQOP1))'
DRL+V7-2.c(6769:12): error: failed to generate expression
DRL+V7-2.c(6770:24): error: unknown identifier 'REQOP2'
DRL+V7-2.c(6770:24): error: invalid operand 'REQOP2'
DRL+V7-2.c(6770:19): error: failed to generate expression
DRL+V7-2.c(6770:15): error: invalid operand '~(1 << ( REQOP2))'
DRL+V7-2.c(6770:12): error: failed to generate expression
-
- Posts: 59
- Joined: Mon Aug 04, 2014 12:59 pm
- Has thanked: 8 times
- Been thanked: 4 times
- Contact:
Re: Wake Up from CAN_BUS
I have solved the problem.
18f25K80.h doesn't have these bits in cancon register unlike 18f2580.h
So I can write cancon = 0x20
or add to 18f25k80 bits intto cancon_ro7
18f25K80.h doesn't have these bits in cancon register unlike 18f2580.h
So I can write cancon = 0x20
or add to 18f25k80 bits intto cancon_ro7