BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 10:44 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Atom 40 and its variables in RAM
PostPosted: Wed Mar 11, 2009 7:20 am 
Offline
Citizen

Joined: Mon Jun 23, 2008 8:39 am
Posts: 18
Dear All,
I have the atom 40 and I want to write a code in which I pass in a variable or array of byte a value with frequency of 1 second.
In this way could the micro crash because of this high frequency? :o

Regards
D. Antonino


Top
 Profile  
 
 Post subject: Re: Atom 40 and its variables in RAM
PostPosted: Wed Mar 11, 2009 3:29 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
If you are talking about writing a variable per second to internal RAM, this is quite doable. You can also write this to internal EEPROM, but this memory can only be written to so many times, and will die around 1 million writes. Check the manual on this.
Take care,
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Atom 40 and its variables in RAM
PostPosted: Wed Mar 11, 2009 3:54 pm 
Offline
Citizen

Joined: Mon Jun 23, 2008 8:39 am
Posts: 18
Thank you for your reply!
I want to write the variable in Ram, not in EEProm, because I know that in EEProm I must be careful...
about interrupts?
If I want to do 8 instructions of "count", for example count P1,1000,var1 - count P2,1000,var2... and so on, I must to wait for 1000 msec * 8 before tha cycle begin again. I want to avoid this delay of 8 seconds, but I desire that all the 8 instructions must be run at the same time...How do it?

Thanks


Top
 Profile  
 
 Post subject: Re: Atom 40 and its variables in RAM
PostPosted: Wed Mar 11, 2009 8:35 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
This is a sticky question.
COUNT makes the pin you select an input, watches for 0-1-0 transitions, and counts each one it sees. The time out you specify (1000 in your example) means 1000 milliseconds, or one second. An interrupt is used to track this time-out. COUNT only works on one pin at a time. If you did this in assembly, you may do more than one at a time, but you are limited by the number of timers available, which is usually two or three for a typical processor.

If you are measuring known, constant signals, like a clock, then you can get around this by using
Code:
COUNT P0, 100, VAR1

That is, measuring for 100 milliseconds, a tenth of a second. You can do eight samples in a row in 800 milliseconds, so you finish in under a second. When done, multiply the variables by 10 to get the final frequency, with tiny inaccuracies.
If your signals are irregular, and you have to sample eight signals, this doesn't work.

There are hardware solutions, like using eight sets of flip-flop ICs, clocked by the external signals of interest. This looks like:
1. Reset the F/F outputs to all zeroes (F/F = Flip-Flop)
2. Enable the F/F clock inputs
3. Start a 1 second timeout in your Atom. When that finishes, you
4. disable clocking of the F/Fs and
5. read the values at the outputs of the F/Fs and store them to variables.
6. Start all over again with 1.
This is a simplistic description. Kindly do not ask for a detailed description and diagram. I only advise and suggest. Try Googling for counter circuits.

Another hardware solution is using any Count/Compare registers (usually called CCP) built into the Atom. Once again, you are limited by having a small number of these registers. This is a matter of coding in assembly after studying the data sheet for the processor. If you're new to processors, this is a daunting task.
Next thing, try this question at the Atom/Pro forum at lynxmotion.com. The people there are very knowledgable about these chips. Or email Basic Micro's support@basicmicro.com.

Take care,
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Atom 40 and its variables in RAM
PostPosted: Mon Mar 16, 2009 8:14 am 
Offline
Citizen

Joined: Mon Jun 23, 2008 8:39 am
Posts: 18
Dear Kenjj,
if I use the timer0 interrupt, do you think that I solve the question about count instruction in 8 input channels?

Regards
Deny


Top
 Profile  
 
 Post subject: Re: Atom 40 and its variables in RAM
PostPosted: Mon Mar 16, 2009 9:41 am 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
No. It still comes down to one pin input at a time, so eight at once is out. You still need to do a hardware counter outside the Atom if you want to do this all at the same time. That would be the eight sets of Flip-Flops as mentioned before, or eight Atoms all running at the same time.
Take care,
kenjj

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO