Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Interupt for peripherals

Status
Not open for further replies.

iamdink

Newbie level 4
Joined
Jul 17, 2010
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
CA
Activity points
1,339
I'd like to use timer driven interrupts for some of my peripheral components. I need to update 4 DAC on an I2C bus and also 2 gain values for PGA on SPI bus. I need to receive 2 ADC updates on an SPI interface.

I figured I'd move I2C in one low time interrupt. No need to worry about devices writing to same bus as only one..

For SPI I have to make semaphore or mutex. This is if I choose to go down multithreaded implementation.

So my question. Is it more effective to implement independent SPI write/read operations in different interrupts. I mean is it faster than keeping them under one interrupt?
 

Hi

You can't use multiple interrupt on the same peripheral at the same time! it will mash your output if you succeed.

whether you need multypale access to the same peripheral from different function at the same time - you will need to create a ququ for data and ququ for process (one process write data to SPI FLASH and the 2nd process write data to ADC etc...)

All the best

Bobi

The microcontroller specialist
 

If you are researching this - timer driven interrupts are called "polling." They are not interrupts in the normal sense. It may be worth you looking up polling to see if there's something under that to help.

The problem with polling is in knowing how much time to allocate to each process.

Do you do "round robbin" where each process gets the same size timeslice one after the other - or do you do some other method.

polling is generally not a good idea for the sort of hardware you are describing if normal interrupts are at all possible.
 

bobcat and 123jack:

I'm using an SPI interface for my ADC. I have 4 sensor inputs for my ADC's. What I planned was to setup 4 16-bit timers set to poll threads. Each of these individual poll threads would have bus-safe logic to poll ADC.

The ADC read call is blocking and will sit and wait forever. I must pull the correct clock select line however. I'll implement bus-safe logic by implementing semaphore.

thread1:
if (active==false)
{
active=true;
cs1 = 0;
ReadADC1(..)
cs1 = 1;
}

So here active will be global indicator specifying that BUS for SPI line is used.
 

Fair enough if thats fast enough for you.
In terms of the most effective means - its very hard
to say without knowing all you know. With polling its all about time and speed of activities and how/when to switch and what happens if you don't get to something fast enough.

AtoD's tend to be fairly slow in my (somewhat limited) experience so you might be OK.

I tend to use flags myself but I think I'd prefer a
real interrupt - but that could just be because I'm used to that. (Last time I did polling was in forth
a couple of decades ago!)

Sorry I can't be more specific.

jack
 

Thanks for help Jack. Alternatively I can use I2C interface which can has a special interrupt built in for asynchronous operation.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top