Show Posts
Pages: [1] 2
1  Products / Arduino Due / Re: Timer Interrupts on Due on: Today at 04:17:56 pm
Using this code, you can set a timer for any of the ISRs TC0_Handler through TC8_Handler, see table of parameters below. It is possible to use the timers without a physically mapped pin, such as TC1 channel 0 (TC3_Handler) shown here:

Code:
volatile boolean l;

//TC1 ch 0
void TC3_Handler()
{
        TC_GetStatus(TC1, 0);
        digitalWrite(13, l = !l);
}

void startTimer(Tc *tc, uint32_t channel, IRQn_Type irq, uint32_t frequency) {
        pmc_set_writeprotect(false);
        pmc_enable_periph_clk((uint32_t)irq);
        TC_Configure(tc, channel, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK4);
        uint32_t rc = VARIANT_MCK/128/frequency; //128 because we selected TIMER_CLOCK4 above
        TC_SetRA(tc, channel, rc/2); //50% high, 50% low
        TC_SetRC(tc, channel, rc);
        TC_Start(tc, channel);
        tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;
        tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;
        NVIC_EnableIRQ(irq);
}

void setup(){
        pinMode(13,OUTPUT);
        startTimer(TC1, 0, TC3_IRQn, 4); //TC1 channel 0, the IRQ for that channel and the desired frequency
}

void loop(){
}

Here is the table of parameters:
ISR/IRQTC        ChannelDue pins
TC0TC002, 13
TC1TC0160, 61
TC2TC0258
TC3TC10none  <- this line in the example above
TC4TC11none
TC5TC12none
TC6TC204, 5
TC7TC213, 10
TC8TC2211, 12

Is there any interference between Timer interrupts and arduino's Serial library? Using this function (see above) to set any timer except TC1 CH0 will cause Serial.available() to stop functioning. Is this a known problem?

Best regards,
Dan.
2  Products / Arduino Due / Re: Timer Interrupts on Due on: December 01, 2013, 08:59:24 am
Hi guys.. I'm new to Arduino Due and was wondering if there is any way to output a clock signal directly on one of the pins without using any interrupts.

Yes, it is possible through using the timer counter channels.
"Each channel can be independently pro-
grammed, through its two operating modes, to perform a wide range of functions
including frequency measurement, event counting, interval measurement, pulse gen-
eration
, delay timing, pulse width modulation and interrupt generation."

Please have a look at
http://www.atmel.com/Images/doc2682.pdf
3  Development / Other Software Development / TFT library add Colour class on: October 17, 2013, 12:16:52 pm
Hello,
I am using the TFT library and found myself handling different colours for background, stroke for in range values, stroke for out of range values etc. I would very much appreciate having a Colour class that could hold the R,G,B values. That would greatly simplify things when dealing with multiple colours.
There would be only 2 methods that need overloading: stroke() and background() .
What do you say? I am willing to do the changes if others think it would improve the library.

What is the usual way of contributing code to the libraries?
Best regards,
Dan.

P.S.
Is it possible to search for a term only in one of the topics on this forum?
4  International / Hardware / Re: TFT screen ufficiale 1.77" non funziona su Arduino Uno smd on: October 15, 2013, 02:48:00 pm
Tested the nightly build and it works with Arduino DUE and hardware SPI. May I ask what exactly was wrong with the TFT library?
Good job Vanzati.
5  International / Hardware / Re: TFT screen ufficiale 1.77" non funziona su Arduino Uno smd on: October 15, 2013, 10:34:52 am
Allegati a questo messaggio trovate gli zip con la versione aggiornata della libreria TFT per IDE 1.0.5 e per IDE 1.5.4

Dovete semplicemente cancellare la libreria che c'รจ dentro la cartella libraries dell'IDE e sostituirla con quella dello zip.

Great, I am going to give it a try with my Arduino DUE in a couple of hours and report back.

In the meantime I have noticed that on the official page there is a link to the screen's data sheet
http://arduino.cc/en/uploads/Main/HTF0177SN-01-SPEC.pdf
and there it says:  Controller ILI9163

Is this information correct ?
6  International / Hardware / Re: TFT screen ufficiale 1.77" non funziona su Arduino Uno smd on: October 13, 2013, 06:38:25 am
The display is good but is a different model and a driver modify is needed.

The display is advertised as ST7735. What model it actually is?
7  International / Hardware / Re: TFT screen ufficiale 1.77" non funziona su Arduino Uno smd on: October 12, 2013, 05:31:17 pm
Hello,
I do not speak Italian, but helped by Google Translate I could understand the messages. It seems I am facing the same problem with the official TFT module, Arduino DUE and Arduino 1.5.4. I am using the TFT library, it compiles without errors but my screen only shows some random lanes. I have the following code in the setup function:
Code:
#include <SPI.h>
#include <TFT.h>

#define cs     10
#define dc     9
#define rst    8
#define sd_cs  7

TFT TFTscreen = TFT(cs, dc, rst);
char sensorPrintout[4];

void setup() {
  Serial.begin(9600);
  TFTscreen.begin();

  TFTscreen.background(0, 0, 0);

  TFTscreen.stroke(255,255,255);
  TFTscreen.setTextSize(2);
  TFTscreen.text("Sensor Value : ",0,0);
  TFTscreen.setTextSize(5);
}


What could be wrong ?
8  Products / Arduino Due / Re: Timer Interrupts on Due on: May 29, 2013, 02:33:28 am
Everything is there. Just do a grep (or file search if not on a *nix os).
The source files even have some comments. You should also have the SAM3X8E datasheet at hand too.
9  Products / Arduino Due / Re: Timer Interrupts on Due on: May 28, 2013, 02:49:38 am
If you include #include <Arduino.h> you should have access to them.
The source code can be found in:
arduino-1.5.2\hardware\arduino\sam\system\libsam\include\tc.h
arduino-1.5.2\hardware\arduino\sam\system\libsam\source\tc.c
10  Products / Arduino Due / Re: Timer Interrupts on Due on: May 27, 2013, 03:12:16 pm
Found the bug:
Code:
  TC_Configure(chTC, chNo,
       TC_CMR_TCCLKS_TIMER_CLOCK4 |
       TC_CMR_WAVE |         // Waveform mode
       TC_CMR_WAVSEL_UP_RC | // Counter running up and reset when equals to RC
       TC_CMR_ACPA_SET |     // RA compare sets TIOA
       TC_CMR_ACPC_CLEAR );  // RC compare clears TIOA

I have to set TC_CMR_ACPA_SET and TC_CMR_ACPC_CLEAR to instruct the counter to change the level on PIOA0 when the counter's value has reached RA/RC
11  Products / Arduino Due / Re: Arduino Due and tone() on: May 27, 2013, 03:10:11 pm
I'll answer my own question:
In order to get your square wave out on TIOA you have to set the appropriate bits on the TC Channel Mode Register:
Code:
  TC_Configure(chTC, chNo,
       TC_CMR_TCCLKS_TIMER_CLOCK4 |
       TC_CMR_WAVE |         // Waveform mode
       TC_CMR_WAVSEL_UP_RC | // Counter running up and reset when equals to RC
       TC_CMR_ACPA_SET |     // RA compare sets TIOA
       TC_CMR_ACPC_CLEAR );  // RC compare clears TIOA

This solution is much accurate than using interrupts but it has the drawback that you have to use the pin associated with the TIOA0 signal (on arduino DUE this is pin 2).

Best regards,
Dan.
12  Products / Arduino Due / Re: Timer Interrupts on Due on: May 26, 2013, 12:27:11 pm
Hello everybody.
I am trying to generate a square wave using timer counters but I do not want to use an interrupt, rather I would like to output to go directly to TIOA0. I have the following configuration of the registers
http://paste.ubuntu.com/5703102/

but I get no output on pin 2 of Arduino Due.
What am I missing?

Best regards,
Dan.
13  Products / Arduino Due / Re: Arduino Due and tone() on: May 26, 2013, 05:39:52 am
I have tried to change your code and configure TC0/Ch0 to use the TIOA0 pin as output for the square wave.
I have a piezo connected to Arduino PIN 2 (which, according to the mapping in http://arduino.cc/en/Hacking/PinMappingSAM3X should be PB25).

It seems that I am doing somethig wrong, since I get no output from pin 2.
If I enable the TC0_IRQn interrupt then I can see my handler being called, which means that at least the timer was configured correctly.

Can you please have a look over my code? I must have done something wrong.
http://paste.ubuntu.com/5703102/

I want to eliminate the need for interrupts and manual bit banging on pin 2.

Best regards,
Dan.
14  Products / Arduino Due / Re: Arduino Due Tone example not working on: May 26, 2013, 05:33:11 am
Check this thread too:
http://forum.arduino.cc/index.php?topic=136500.0
15  Products / Arduino Due / Re: i2cdevlib + MS561101BA + due on: April 25, 2013, 12:28:48 am
Thx,
I'll give it a try and keep you posted on the results.
Pages: [1] 2