The Godfather talking
Share your stuff or I will make you regret it.
Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 11, 2016, 12:52:43 12:52


Login with username, password and session length


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

Posts: 37

Thank You
-Given: 3
-Receive: 5


« on: March 30, 2009, 12:13:38 12: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: 88

Thank You
-Given: 45
-Receive: 10


« Reply #1 on: March 30, 2009, 04:34:20 16: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: 103

Thank You
-Given: 96
-Receive: 82


« Reply #2 on: March 30, 2009, 08:06:28 20: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: 2018

Thank You
-Given: 514
-Receive: 477


Top Topic Starter


« Reply #3 on: March 30, 2009, 09:11:22 21: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, 09:17:25 21:17 by metal » Logged

nothing to say..
samir
Active Member
***
Offline Offline

Posts: 180

Thank You
-Given: 26
-Receive: 21


« Reply #4 on: March 31, 2009, 05:01:00 05: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
Junior Member
**
Offline Offline

Posts: 37

Thank You
-Given: 3
-Receive: 5


« Reply #5 on: April 05, 2009, 10:37:31 10: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
V.I.P
Senior Member
*****
Offline Offline

Posts: 375

Thank You
-Given: 152
-Receive: 106


If the van is a Rockin'...


WWW
« Reply #6 on: April 05, 2009, 07:25:04 19: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
V.I.P
Junior Member
*****
Offline Offline

Posts: 74

Thank You
-Given: 53
-Receive: 28


« Reply #7 on: April 07, 2009, 09:02:59 21: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, 08:44:19 08: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, 03:52:04 03: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, 03:07:01 03: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: 175

Thank You
-Given: 71
-Receive: 38


« Reply #11 on: July 07, 2009, 07:39:09 19: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