Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M302: Size of Register must be 8, 16 or 32 Bits #237

Open
kossnikita opened this issue Oct 25, 2023 · 8 comments
Open

M302: Size of Register must be 8, 16 or 32 Bits #237

kossnikita opened this issue Oct 25, 2023 · 8 comments

Comments

@kossnikita
Copy link
Contributor

From CMSIS SVDConv docs

Message Number Type Message Text
M302 ERROR Size of Register 'NAME':'NUM' must be 8, 16 or 32 Bits

This limitation is not obvious to me. For example, it is easier to create a 12-bit register for a 12-bit ADC than a 32-bit register with only one field.
svd2rust handles this by creating an unsafe method for working with such registers. But CMSIS prohibits such svd files. Should utilities handle this error?

@kossnikita
Copy link
Contributor Author

I think this issue for rust-embedded/svd. Feel free to move it.

@burrbull
Copy link
Member

This limitation is not obvious to me. For example, it is easier to create a 12-bit register for a 12-bit ADC than a 32-bit register with only one field.

Register is how CPU reads/writes memory. It does it by u8,u16,u32, u64 depending on architecture. Even if it physically only 12 lines are connected to register mapped on memory.
Field is abstraction which you can push/pop from register.

@burrbull
Copy link
Member

P.S. Even if you create u8 or u16 register on 32-bit arch, first you need to check in reference manual can this register or all registers of peripheral be manipulated in byte or word mode

@kossnikita
Copy link
Contributor Author

Do you mean that there are modes in which the processor can read or write registers differently? I thought that the data bus always has a fixed width. For example, a 32bit processor will always read/write all 32bits.

@burrbull
Copy link
Member

burrbull commented Oct 25, 2023

Do you mean that there are modes in which the processor can read or write registers differently?

Yes (at least for ARM), depending on asm command you are using to read/write register microprocessor can react differently.

Usually this is allowed for data registers, for example SPI DR, TIM ARR, etc. This is what <size> tag about.

изображение

@kossnikita
Copy link
Contributor Author

Thank you, it's clear now. So should introduce this limitation into the svdtool or into the svd?

@burrbull burrbull transferred this issue from rust-embedded/svdtools Oct 25, 2023
@burrbull
Copy link
Member

Yes, make sense in svd.

@burrbull
Copy link
Member

related to #247

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants