Let's say I want to set 12 bits/pins simultaneously with specific values 0/1 to gpio output register but I do not want to change other bits - must be done with one 32bit word write and possibly one write instruction.
Do I have to disable/enable bits with mask first? I don't want to change settings of other pins.
Should it be done with combination of W1TC/W1TS ?
I am looking for fastest possible way - best with asm instructions if possible. Single REG_WRITE is ok too.
Thanks for any suggestions
Writing to GPIO_OUT_REG to only specific pins
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Writing to GPIO_OUT_REG to only specific pins
There's no way to mask bits; the way to go would be to either use a read/modify/write on the GPIO value register (but watch out with multitasking there) or use a W1TC/W1TS combo. From an architectural point of view, I'd think W1TS/W1TC would be faster (no reads involved, writes can be queued) but it does have the slight disadvantage that you have an intermediate value on your GPIOs at some point.
Re: Writing to GPIO_OUT_REG to only specific pins
So operations steps would be:
val => W1TS
val ~= val
val => W1TC
How that would look in asm ?
val => W1TS
val ~= val
val => W1TC
How that would look in asm ?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Writing to GPIO_OUT_REG to only specific pins
You probably want to mask the bits you don't want to touch.
W1TS <= val & mask
W1TC <= (~val) & mask
I'll leave the assembly to someone else, but chances are it's not going to be that much faster than C. (Maybe a bit because C declares these as volatile; you could work around that though.)
Re: Writing to GPIO_OUT_REG to only specific pins
Thanks. Well I use whole word only with needed bits so masking is not necessary.
Actually XOR operation might not be needed and data will be precalculated ready to write)
I want to use assembler instructions to repeat inline few times for speeding execution.
Actually XOR operation might not be needed and data will be precalculated ready to write)
I want to use assembler instructions to repeat inline few times for speeding execution.
Who is online
Users browsing this forum: Baidu [Spider] and 76 guests