Go Down

Topic: Arduino.h and wiring_digital.c problem. (Read 7 times) previous topic - next topic

Baltasar

Thanks again cmaglie, your fix on the Arduino.h puts everything working on the right spot.  :)
I hope it will sent to GIT so the last version comes out fixed with that.

Now all code works like a charme, I wonder now if we still can not optimize it a bit more since we are still using on the ports writing routines the REG_PIOD_SODR register, do you think this can also be changed for ODSR?

The problem with ODSR is when you write something there what was before gets cleared, so I think I need to do the proper logic just to change what´s new and maintain what was previous, no?
Check all my projects based on Atmel/Arduino -> www.aqualed-light.com

alvesjc



Ok ok ok, if I get it right, that means that I'll not need to add the ampersand to "portOutputRegister(digitalPinToPort(13))" as your previous suggestion, because "( &(port->PIO_PDSR) )" will already return that pointer, right?


exactly.


By the way, can you explain me the meaning of "->"? Or point me to some place to read about it?


when you have a pointer to a structure the "->" operator is used to access a member of the pointed structure. Without this operator you should write something like:

Quote
(*PIOA).PIO_PDSR


whete *PIOA is the structure instance pointed by PIOA and .PIO_PDSR is the member selector. You need also the parenthesis because . has higher priority versus *. Since this kind of access is used very often, the C language defines the -> operator so you can write a more concise:

Quote
PIOA->PIO_PDSR


if you need more info a google search for "pointer to structure" will give you a lot of articles.


Ok, thank you for your time explaining. ;)

BR,

Joao

alvesjc



I'm waiting the results of your test! :-)


Ok, working fine now, thanks for your help!

With direct port communication with SODR and CODR for data pins we have gained +-13s in UTFT Demo code loop, a HUGE difference!!!

Regards,

Joao

amolinero

Hello alvesjc

Can you put the sample code you already it works.
I refer to the set of sbi, cbi.

It would be far better that you put the modified UTFT to download.

I have cast a write methods for UTFT ports that I have not been able to apply, but I set the display directly and go very fast, I would like to adapt the library and send it to the developer to UTFT but I'm missing that part.

Thanks

amolinero

After doing some tests, I see that it works by putting the code which says cmaglie.
Quote
REG_PIOA_OWER = 0xFFFFFFFF;
  REG_PIOB_OWER = 0xFFFFFFFF;
  REG_PIOC_OWER = 0xFFFFFFFF;


then hit the code.

Code: [Select]
#define sbi(reg, mask) *reg |= mask
#define cbi(reg, mask) *reg &= ~mask

int led = 13;
volatile uint32_t * Registro;
uint32_t Mascara;

// the setup routine runs once when you press reset:
void setup() {               
  REG_PIOA_OWER = 0xFFFFFFFF;
  REG_PIOB_OWER = 0xFFFFFFFF;
  REG_PIOC_OWER = 0xFFFFFFFF;
  Registro = portOutputRegister(digitalPinToPort(led));
  Mascara = digitalPinToBitMask(led);
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);   
 
 
}

// the loop routine runs over and over again forever:
void loop() {
  sbi(Registro,Mascara);
  delay(1000);               // wait for a second
  cbi(Registro,Mascara);
  delay(1000);               // wait for a second
}



Go Up