Byte/short access to peripherals

hpeteranvin
Posts: 29
Joined: Tue Feb 28, 2017 3:44 am

Byte/short access to peripherals

Postby hpeteranvin » Tue Jan 30, 2018 8:35 pm

Is is legal to perform 8- or 16-bit accesses to peripheral registers? If so, what are the semantics (e.g. reads are ok, but not writes; writes have proper byte enables; writes go through but unaccessed bytes are effectively written with zero?)

If it matters, I am primarily interested in the GPIO registers.

Thanks,

-hpa

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Byte/short access to peripherals

Postby ESP_Angus » Wed Jan 31, 2018 8:29 am

Unfortunately not. I think this does work in some isolated cases (I can't remember which) but it's not supported.

What is your goal with the GPIO registers?

hpeteranvin
Posts: 29
Joined: Tue Feb 28, 2017 3:44 am

Re: Byte/short access to peripherals

Postby hpeteranvin » Thu Feb 01, 2018 4:49 am

I'm trying to eliminate every possible cycle of latency I can between an incoming event and its response. Doing byte/word accesses would have eliminated a fair bit of shifting and masking.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Byte/short access to peripherals

Postby Vader_Mester » Thu Feb 01, 2018 6:56 am

The need for such access largely depends on what you want to achieve.
What do you want to get with such operations?

Vader[Ben]

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

ESP_Sprite
Posts: 9708
Joined: Thu Nov 26, 2015 4:08 am

Re: Byte/short access to peripherals

Postby ESP_Sprite » Thu Feb 01, 2018 11:48 am

FWIW, Xtensa has a dedicated shift-and-mask instruction, so it's possible you won't gain as much as you think you'd do.

Wrt your original question: Officially, we guarantee only 32-bit accesses to the port and nothing else. (Except for a few very specific cases as indicated in the TRM; iirc the UART data port is one.)

Unoficially: If it works for you, it works :) My personal guess would be that the problem will be that the GPIO peripheral doesn't have its byte/word-select lines connected, so chances are that if you do a byte/word write, you write 0's (or whatever else the Xtensa decides to set the bus to) to the other bytes in the port. I see no reason why reading from a non-FIFO-register (like the GPIO registers) wouldn't work.

hpeteranvin
Posts: 29
Joined: Tue Feb 28, 2017 3:44 am

Re: Byte/short access to peripherals

Postby hpeteranvin » Thu Feb 01, 2018 8:59 pm

That pretty much summarizes what I need to know to do further experimentation. Thank you!

Who is online

Users browsing this forum: No registered users and 101 guests