Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

can bus sleep problem

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Fri May 10, 2019 6:38 am    Post subject: can bus sleep problem Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Sat May 11, 2019 2:39 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Sun May 19, 2019 3:33 pm    Post subject: Reply with quote

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
View user's profile
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Wed Jul 24, 2019 8:55 am    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Wed Jul 24, 2019 11:07 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
Ghitab

Bascom Member



Joined: 25 Sep 2012
Posts: 10

PostPosted: Wed Jul 24, 2019 8:47 pm    Post subject: Reply with quote

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
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Thu Jul 25, 2019 9:10 am    Post subject: Reply with quote

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
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum