The Godfather talking
This is god damn my place! Capisci?
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 25, 2024, 01:18:16 13:18


Login with username, password and session length


Pages: [1]
Print
Author Topic: How to write this program?  (Read 4455 times)
0 Members and 1 Guest are viewing this topic.
nanocycle
Newbie
*
Offline Offline

Posts: 20

Thank You
-Given: 3
-Receive: 5


« on: March 30, 2009, 11:13:38 11:13 »

Hi everybody,

Suppose that we have a AVR micocontroller and some inputs and outputs (digital and analog and serial) as picture.We have a process and micro is checking all inputs and outputs and answering to all of them.
The question is this.I want to write value in EEPROM of micro by pressing Set button and increasing and decreasing value by up and down buttons Withou disordering the rest of process of micro.In fact micro is doing it's process but also gives us capability for writing value in EEPROM.(Similar to parallel processing).
Also i don't want to use another micro.
How is it possible?



Regards,
 
Logged
alberto110
Junior Member
**
Offline Offline

Posts: 93

Thank You
-Given: 50
-Receive: 10


« Reply #1 on: March 30, 2009, 03:34:20 15:34 »

the micro has only on core (cpu ) and can do one thing at a specific of time . you can write a program that check inputs write to outputs and answer
to buttons ( consequently increasing and decreasing value ) . the micro run your program very fast and it seems all  functions runing parallel .
surly when cpu checking switches can't read from digital inputs . but if cpu is much faster than the inputs ( like switches ) you will not have any problem .
for very fast inputs , you should use interrupt . also include timers into your project for timing .

best regard
Logged
pablo2048
Active Member
***
Offline Offline

Posts: 113

Thank You
-Given: 133
-Receive: 86


« Reply #2 on: March 30, 2009, 07:06:28 19:06 »

If You have free timer try to write simple periodic interrupt handler. In this handler You can do what You need...
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #3 on: March 30, 2009, 08:11:22 20:11 »

Why do you want to do that? What do you mean by disorder here? What are those processes being read and output so important that prevents you using an interrupt to handle another task, buttons, etc... Even intel processor slices processing time among different processes, it also uses interrupts to handle the mouce...

As long as you have a single CPU/core, you will never have parallel processing... When you say "disorder" it means that your program is being executed by diffrerent CPUs/cores such that tasks/threads don NOT interfer with each other, which is another story... or that you don not understand how the interrupt is working... Interrupts don not disorder program execution, they redirect it somewhere else that you specify, and then return back to the next instruction that was supposed to be executed if there was no interrupt...

First of all, you should have read resources about handling buttons.. Your diagram implies that you have no idea... You might have found a readily available routine somewhere... or you are still a beginner...

Now introduce to other members what exactly on your mind buddy.. so they can help you further... forget the term "parallel processing" for one AVR chip  Kiss

You might want to disable the interrupts when you read/output data, this is a wise thing to do inorder not to miss your data, but don not disable them for a long time, then you will miss button pressing events.
« Last Edit: March 30, 2009, 08:17:25 20:17 by metal » Logged
samir
Active Member
***
 Muted
Offline Offline

Posts: 181

Thank You
-Given: 27
-Receive: 21


« Reply #4 on: March 31, 2009, 04:01:00 04:01 »

if all above suggestion won't work then you need processor with more than one core like Freescale's XGATE,so you can have two process running parallel.
Logged
nanocycle
Newbie
*
Offline Offline

Posts: 20

Thank You
-Given: 3
-Receive: 5


« Reply #5 on: April 05, 2009, 09:37:31 09:37 »

Thanks my friends.Very good points and useful information.
Now if i want to use another micro,which type of connection is good?
SPI is good?
is it possible that two micro communicate by I2C?

regards,
Alireza
Logged
oldvan
Senior Member
****
Offline Offline

Posts: 372

Thank You
-Given: 154
-Receive: 107


If the van is a Rockin'...


WWW
« Reply #6 on: April 05, 2009, 06:25:04 18:25 »

SPI or I2C would be good if the processors are close together. 
One-Wire can move data with minimum pin count.

For greater distances you could use RS232, CAN, or even
something of your own creation.
Logged

Give a man a fish and you feed him for a day.
Teach a man to fish and he will sit around in a boat drinking beer all day.
flyback
Junior Member
**
Offline Offline

Posts: 84

Thank You
-Given: 73
-Receive: 39


« Reply #7 on: April 07, 2009, 08:02:59 20:02 »

Please note that you already take MISO, MOSI, CLK pins to read switches, so you no longer can use SPI communication. Or you may modify your schematic. Smiley
Logged
ali_asadzadeh
Junior Member
**
Offline Offline

Posts: 82

Thank You
-Given: 5
-Receive: 12


« Reply #8 on: April 14, 2009, 07:44:19 07:44 »

maybe you can solve the problem by using a RTOS!
there are several free ones out there.use www.freertos.org it's free and have good stability.
Logged
LabBoy
Guest
« Reply #9 on: May 08, 2009, 02:52:04 02:52 »

The real-time processing is necessary for your work. You can use a timer interrupt to construct the software timers and use them for manage the operation timing. This technique was called "The Software Timer". With this solution you will get the Multitasking Real-Time processing style without using any RTOS like FreeRTOS or uC-OS.
Logged
sittichoke
Newbie
*
Offline Offline

Posts: 7

Thank You
-Given: 8
-Receive: 2


« Reply #10 on: July 06, 2009, 02:07:01 02:07 »

between process will have gap time, it's enough for write EEPROM, by do not interrupt main process
try to measure time of each process, you will found the gap time
Logged
Mega32
Active Member
***
Offline Offline

Posts: 179

Thank You
-Given: 183
-Receive: 37


« Reply #11 on: July 07, 2009, 06:39:09 18:39 »

Just start en eeprom write , and poll for the write completion in the "main loop".

Or check for completion in a timer interrupt.

Writing eeprom on a M32 is quite slow , so dont loop around the write completion.

You don't need multicores or anything like it , the M32 will do this fine.

Do take note of flyback's comment and move the buttons away from MISO/MOSI/SCK , they are used for SPI and for ISP programming. Watch out for using SS for digital input , if you want to use SPI.

You could move them to the free pins of PORTC .
Remember to disable JTAG (fuse setting) , if you use PORTC.
 
Remember to power AVCC and decouple both VCC & AVCC with 100nF to GND.

If you want to use RS232 , don't rely on the internal oscillator it is too unstable , use an XTAL or oscillator.


Mega32
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC