Click here to Skip to main content
15,891,657 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:07
Aescleal25-Sep-10 10:07 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:15
Trevor Johansen25-Sep-10 11:15 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 8:55
sitebuilderLuc Pattyn25-Sep-10 8:55 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 9:34
Trevor Johansen25-Sep-10 9:34 
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 9:45
sitebuilderLuc Pattyn25-Sep-10 9:45 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 10:57
Trevor Johansen25-Sep-10 10:57 
AnswerRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 11:18
sitebuilderLuc Pattyn25-Sep-10 11:18 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 11:56
Trevor Johansen25-Sep-10 11:56 
True, I know on AVR's you write a 1 to the bit to clear an interrupt and if I read the register before the ISR is called that would be a problem. This could get quite difficult now...

How the heck to the people who write the header files for chips do these things then? For example here is some bus handling setup from an ARM:

RCC->APB1RSTR = 0x00000000;
RCC->APB2RSTR = 0x00000000;
RCC->AHBENR = 0x00000014;
RCC->APB2ENR = 0x00000000;
RCC->APB1ENR = 0x00000000;
RCC->CR |= 0x00000001;
RCC->CFGR &= 0xF8FF0000;
RCC->CR &= 0xFEF6FFFF;
RCC->CR &= 0xFFFBFFFF;
RCC->CFGR &= 0xFF80FFFF;
RCC->CIR = 0x00000000;


They must have a different implementation of how these registers get written as the RCC->CR |= 0x00000001; will cause errors like you say if any bit besides the first one is set. This would be alot easier if their was open source code to walk through and see exactly how changes effect the system.

My goal is to make these register assignments much easier to use. Instead of writing a 32bit value to the entire register or even ORing the bit you want changed in it would be better to have bit level access with the names available to make the code more readable.

For example if you want to enable the clock to timer1 you would write:
<br />
RCC->APB2ENR = 0x00000800<br />

but I want to add access like:
<br />
RCC->APB2ENR->TIM1EN = true;<br />

or better yet:
<br />
HW->Reset_Clock_Control->APB2_Bus_Enables->Timer_1 = true;<br />


I like the functionality in Eclipse IDE that shows the documentation of the thing you have intelisense popping up for you so when you type HW-> you given not only a list of available hardware settings but a description of them. My compiler does not do this but I can at least include documentation in the header and provide an open source file so people know what they heck is going on. as a 1072 page manual is annoying and if you search adobe usually freezes for a few minuets first.
GeneralRe: Memory aligned bit fields Pin
Luc Pattyn25-Sep-10 12:14
sitebuilderLuc Pattyn25-Sep-10 12:14 
GeneralRe: Memory aligned bit fields Pin
Alain Rist25-Sep-10 9:57
Alain Rist25-Sep-10 9:57 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 10:19
Aescleal25-Sep-10 10:19 
AnswerRe: Memory aligned bit fields Pin
Alain Rist25-Sep-10 11:26
Alain Rist25-Sep-10 11:26 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 22:31
Aescleal25-Sep-10 22:31 
GeneralRe: Memory aligned bit fields Pin
Trevor Johansen25-Sep-10 10:51
Trevor Johansen25-Sep-10 10:51 
GeneralRe: Memory aligned bit fields Pin
Aescleal25-Sep-10 22:34
Aescleal25-Sep-10 22:34 
QuestionDirectX - Antialiasing and Plotting Pixels Query [Moved] Pin
simon alec smith24-Sep-10 9:52
simon alec smith24-Sep-10 9:52 
QuestionHow to process multiple commands on CAccessor. Pin
Spawn@Melmac24-Sep-10 8:36
Spawn@Melmac24-Sep-10 8:36 
QuestionGetHeaderCtrl returns null Pin
genush24-Sep-10 6:09
genush24-Sep-10 6:09 
AnswerRe: GetHeaderCtrl returns null Pin
genush24-Sep-10 7:39
genush24-Sep-10 7:39 
QuestionPop sound at the end of playing .wav audio Pin
Danzy8324-Sep-10 2:34
Danzy8324-Sep-10 2:34 
AnswerRe: Pop sound at the end of playing .wav audio Pin
Code-o-mat24-Sep-10 3:03
Code-o-mat24-Sep-10 3:03 
GeneralRe: Pop sound at the end of playing .wav audio Pin
Danzy8324-Sep-10 3:11
Danzy8324-Sep-10 3:11 
GeneralRe: Pop sound at the end of playing .wav audio [modified] Pin
Code-o-mat24-Sep-10 4:43
Code-o-mat24-Sep-10 4:43 
QuestionDelete a View Pin
john563224-Sep-10 1:24
john563224-Sep-10 1:24 
AnswerRe: Delete a View Pin
Eugen Podsypalnikov24-Sep-10 2:29
Eugen Podsypalnikov24-Sep-10 2:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.