View previous topic :: View next topic |
Author |
Message |
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Fri May 10, 2019 6:38 am Post subject: can bus sleep problem |
|
|
Hi. I made a system that read a car remote control and count number of button press, then set some ouputs acording to number I set . System works ok for couple of days and then no more wake up . I use atmega16m1 with TJA1055 as can transceiver and voltage regulator for the system is driven by INH pin of tja. When goes to sleep , tja cuts power to atmega and stay in low power consumption mode. When a can frame wakes tja from sleep, INH pin is high again and have again voltage to atmega. I study tja 1055 pdf but cant figure why system not wake up from time to time. Any ideea is welcome.
Thank you.
(BASCOM-AVR version : 2.0.8.1 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Sat May 11, 2019 2:39 pm Post subject: |
|
|
ok, so you cut the complete power of the micro?
why not using a sleep mode of the processor?
maybe the rise time of the power is not ok. i guess the processor does not start up. otherwise it would work. try different xtal clock times. depending on the rise time of the power supply some chips have problems. _________________ Mark |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Sun May 19, 2019 3:33 pm Post subject: |
|
|
Thank you Albert for advice. I replace crystal from 16mhz to 4 mhz and seems ok so far, will test more.
I configure fuse to have 14ck startup time without aditional delay but when I measure time from apply vcc and first instruction(set ouput for can transceiver) I have around 4.2 ms. I use Cksel(3-0) 1101 and sut1=0, sut0=1 and 4mhz crystal.
Thank you. |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Wed Jul 24, 2019 8:55 am Post subject: |
|
|
Little update. So far is ok with 4mhz crystal.
I have another question , I would like to use can timer TTC to send message with a period of 20ms. How to use CANTTC function?
I enable ENOVRT in Cangie register, and in CAN_TOVF intterupt I toggle one output to test how it works. But I can't figure out how to load CANTTCL and CANTTH register to be able to change period.
Thank you. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Wed Jul 24, 2019 11:07 am Post subject: |
|
|
you can write to CANTTC register which is a WORD register. bascom will handle it for you. (the correct order of low and high byte writing/reading) _________________ Mark |
|
Back to top |
|
|
Ghitab
Joined: 25 Sep 2012 Posts: 10
|
Posted: Wed Jul 24, 2019 8:47 pm Post subject: |
|
|
Thank you for answer. I tried but bascom accept CANTTCH and CANTTCL only or I didnt understend what you mean.
I attach file that I test. Is same file as above with crystal change to 8mhz . I add CAN_TOVF int, load CANTTCH and CANTTCL, set prescaller to 1 then enable bit0 in CANGIE register.
In CAN_TOVF I toggle one output to test but when I check with scope I have square signal with period of 65.535ms not 20ms as I expect . It seem that timer start from 0 every time. I tried to disable can controller, load ttc register then reenable again but same. This timer need other routine to load ttc register? Or maybe any member use this function and can help me.
Thank you again. |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5905 Location: Holland
|
Posted: Thu Jul 25, 2019 9:10 am Post subject: |
|
|
in your code i see : On Can_int Can_int_
please do not use _ for this purpose. it is intended as line continuation character.
to fix canttc: edit the dat file and find the [WIO] section.
then add :
[WIO]
CANTTC = $E8
and save the file.
in your code you use CANTTC as a word variable.
when the int occured you need to clear it yourself by writing a 1. like : cangit.ovrtim=1
you best read the datasheet about these registers. _________________ Mark |
|
Back to top |
|
|
|