Author Topic: RTC  (Read 8521 times)

0 Members and 1 Guest are viewing this topic.

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #25 on: June 29, 2016, 06:53:36 pm »
My COMPILER WARNINGS are only no previous prototype for my two functions
I modified by
Code: [Select]
 
 if(RTC->MODE0.INTFLAG.reg==0)

But I don't understand :
Quote
Also, why do you set direction 10 times in a row?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #26 on: June 29, 2016, 06:57:23 pm »
My COMPILER WARNINGS are only no previous prototype for my two functions
It should complain about statement with no effect on this line "RTC_READREQ_ADDR(0x10);". If it does not, then go into compiler setting and enable all the warnings you can.

I modified by
Ok, so why are you checking for 0?

But I don't understand :

What is this for?
Code: [Select]
   for(int i=0; i<10;i++)
PORT->Group[0].DIRSET.reg = PORT_PA09;
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #27 on: June 29, 2016, 07:08:07 pm »
The loop was kind of delay but I can take it off and put it this way
« Last Edit: July 01, 2016, 06:50:29 am by CLARAAA »
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #28 on: June 29, 2016, 07:10:26 pm »
But the major problem is in the COnfig_RTC () function when I would do:

Code: [Select]

RTC->MODE0.READREQ.reg |= RTC_READREQ_RCONT|    //Read continuously
  RTC_READREQ_ADDR(0x10);
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #29 on: June 29, 2016, 08:34:13 pm »
But the major problem is in the COnfig_RTC () function when I would do:
What's the problem?

Have you looked at my MCU starter projects - https://github.com/ataradov/mcu-starter-projects/tree/master/samd21 ? There is a working timer implementation. It is nt based on RTC, but I don't see why it would matter in this case.
Alex
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2549
  • Country: us
Re: RTC and WATCHDOG SAM
« Reply #30 on: June 29, 2016, 10:57:48 pm »
I can't figure out what the program suppose to do.
Maybe, the OP can describe what he's trying to do and the requirements for the program.  (With OUT talking about WDT and RTC).  A general description would really help.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #31 on: June 29, 2016, 11:00:03 pm »
He wants to read ADC sample every second based on a timer. At the moment he tries to make timer work. The next stage will be ADC.
Alex
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2549
  • Country: us
Re: RTC and WATCHDOG SAM
« Reply #32 on: June 29, 2016, 11:24:37 pm »
So, all he needs to do is setup a loop in the main routine where he reads the ADC and then has a 1 sec delay at the end. 

If he really needs it to sample at exactly 1Hz, then he could setup a 1Hz timer interrupt that would sample the ADC and set a flag for an infinite loop in the main function where he can check the flag and do whatever processing needs done.  He could read the ADC in the main function instead of the interrupt time in order to get into and out of the interrupt as fast as possible.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #33 on: June 29, 2016, 11:26:23 pm »
I agree, but it is hard when you have no [embedded] programming experience. And that's exactly what is going on in this thread.
Alex
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2549
  • Country: us
Re: RTC and WATCHDOG SAM
« Reply #34 on: June 29, 2016, 11:29:05 pm »
Okay.  Plus the language barrier.  I have 35+ years of professional software development experience so this all seems trivial to me.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #35 on: June 30, 2016, 05:42:10 am »
You still have not fixed RTC_READREQ_ADDR(0x10); thing. I'm not going to help you if you are not going to listen.

I gave you a working code, use it.

Also, start giving more information. If you say "stuck", tell us exactly where it is stuck.
« Last Edit: June 30, 2016, 05:45:25 am by ataradov »
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #36 on: June 30, 2016, 05:47:05 am »
I don't understand because in the datasheet :ADDR is read-only constant of 0x10
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #37 on: June 30, 2016, 05:51:36 am »
In your link it is a function with TC , not a module RTC
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #38 on: June 30, 2016, 05:52:04 am »
So what? Your C is wrong.

You have two statements:
Code: [Select]
RTC->MODE0.READREQ.reg |= RTC_READREQ_RCONT;    //Read continuously
and
Code: [Select]
  RTC_READREQ_ADDR(0x10);

The first one is fine, the second one has no effect and compiler should complain about it. If it does not, you need to enable warnings. At this point compiler is smarter than you, so you should listen to it and fix any warnings it gives.

It is a valid point that this field is constant fore this specific peripheral, on other peripherals it is not constant. So author of the original code (which you copy-pasted with errors) had intention to indicate that this filed is set to 0x10. This is done for code readability and maintainability.
Alex
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #39 on: June 30, 2016, 05:55:49 am »
In your link it is a function with TC , not a module RTC
I gave you code for RTC as well in this thread.

Why do you need RTC? Is there a real reason for this?
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #40 on: June 30, 2016, 06:00:29 am »
RTC->MODE0.READREQ.reg |= RTC_READREQ_RCONT;            //Read continuously

I tried to compile by removing this line of code, when I removed it remains blocked in the following line of code allows activate the RTC and if I let it rest stop on this line

Code: [Select]
RTC->MODE0.READREQ.reg |= RTC_READREQ_RCONT;    //Read continuously

Even when I delete the statement with ADDR. I find it very strange
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #41 on: June 30, 2016, 06:04:27 am »
I tried to compile by removing this line of code, when I removed it remains blocked in the following line of code allows activate the RTC and if I let it rest stop on this line
Again, you are not making any sense.

This entire read request thing is completely inconsequential to anything here. It is just a nice optimization.

Even when I delete the statement with ADDR. I find it very strange
The line with ADDR did absolutely nothing. Removing or adding it would not change anything.
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #42 on: June 30, 2016, 06:35:51 am »
so I do not see why it remains locked in this function
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #43 on: June 30, 2016, 06:37:28 am »
so I do not see why it remains locked in this function
Too bad you would not tell us where it is locked exactly.

And since you won't reply why you need RTC and regular timer will not work, I'll let you deal with this on your own.
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #44 on: June 30, 2016, 06:57:26 am »
it is locked exactly here:
Code: [Select]
RTC->MODE0.READREQ.reg |= RTC_READREQ_RCONT;    //Read continuously
I would like to use the RTC module to use another mode of this module. But first, I'd like to use the RTC in mode 0 .
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #45 on: June 30, 2016, 07:00:52 am »
There is nothing to lock in this instruction. Furthermore, you can completely remove it with no harm to actual operation of the module.

How do you check that it is locked?
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #46 on: June 30, 2016, 07:33:28 am »
At the launch of the step mode remains locked in this statement and if I delete it blocks the next line concerning the activation of the module RTC
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #47 on: June 30, 2016, 07:37:59 am »
Switch to disassembly view and step through individual instructions to find out what is happening exactly.
Alex
 

Offline CLARAAATopic starter

  • Contributor
  • Posts: 20
  • Country: dz
Re: RTC and WATCHDOG SAM
« Reply #48 on: June 30, 2016, 07:41:57 am »
Activation of the RTC module does not happen, but no indication is given me suddenly I do not know what to do
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11260
  • Country: us
    • Personal site
Re: RTC and WATCHDOG SAM
« Reply #49 on: June 30, 2016, 07:48:18 am »
I told you exactly what to do - "Switch to disassembly view and step through individual instructions to find out what is happening exactly."

This is very basic stuff. If you can't get it to work, then start with known working projects and modify them. There are a lot of thins than can go wrong, and step by step modifications will make it much easier to debug.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf