Переписываюсь с саппортом. То ли я чего то не понимаю, то ли саппорт, рассудите плиз. Вот наша переписка:
Я:
Цитата
In the User Guide for MSP430F54XX said (for example for TimerA): NOTE: All registers have word or byte register access. For a generic register ANYREG, the suffix "_L" (ANYREG_L) refers to the lower byte of the register (bits 0 through 7). The suffix "_H" (ANYREG_H) refers to the upper byte of the register (bits 8 through 15). So it means that e.g. register TA0CTL which is 16 bit width can be byte accessed either MSB byte or LSB byte. So I tried to modify only MSB byte using the following simple code: unsigned char* p = (unsigned char*)0x341; *p = 0x1; But as the result only LSB byte was was modified. This is true also e.g. DMA registers and I suppose for all periphery registers. If try to modify simple RAM memory region such way no problem occurs. msp430f5418 rev L was used. Is there byte access to periphery registers in 5x uC?
Они:
Цитата
Why do you use 'char' here - which is a 8 bit size variable?
I would recommend to use e.g. the predefined values for setting to TA0CTL which can be found in header files or also in TI code examples.
Я:
Цитата
The sample code that I wrote in my question was just to illustrate the problem I had. The problem was with writing periphery registers which are located at odd addresses. Just for illustration I took TimerA and wrote value to TA0CTL using explicit address 0x341. In my main code of course I use predefined values such as TA0CTL etc.
So my question is: if it is possible to have byte access to periphery registers in MSP430F54xx as it declared in UserGuide? Or may be I didn't understand something.
Они:
Цитата
I think the problem is caused as you are using 'char' in your code which is a 8bit variable.
In the examples I sent you can see it's possible to address 16 bit - could you please test your code without usage of 'char'?
Я:
Цитата
But why I can not use 'char' (8bit) in case I want to access only byte??
Ok, let's abstract our mind from C language. Can I access periphery registers using this assembler code:
mov.b #1, &0x341
where 0x341 is the explicit address of the odd part of TA0CTL? According to UserGuide I thought that "yes, I can." But really this command changes only even part of TA0CTL (at 0x340 address).
Они:
Цитата
Please be aware that you need to use the MOV.W command to have access/write to this registers. There are several code examples which show e.g.
mov.w #128,&TA1CCR0 ; PWM Period/2
mov.w #OUTMOD_6,&TA1CCTL1 ; CCR1 toggle/set
mov.w #32,&TA1CCR1 ; CCR1 PWM duty cycle
mov.w #OUTMOD_6,&TA1CCTL2 ; CCR2 toggle/set
mov.w #96,&TA1CCR2 ; CCR2 PWM duty cycle
mov.w #TASSEL_2 + MC_3 + TACLR,&TA1CTL
In header file you find the addresses of this registers e.g.
#define TA0CTL_ (0x0340) /* Timer0_A5 Control */
DEFCW( TA0CTL , TA0CTL_)
#define TA0CCTL0_ (0x0342) /* Timer0_A5 Capture/Compare Control 0 */
DEFCW( TA0CCTL0 , TA0CCTL0_)
#define TA0CCTL1_ (0x0344) /* Timer0_A5 Capture/Compare Control 1 */
DEFCW( TA0CCTL1 , TA0CCTL1_)
#define TA0CCTL2_ (0x0346) /* Timer0_A5 Capture/Compare Control 2 */
DEFCW( TA0CCTL2 , TA0CCTL2_)
#define TA0CCTL3_ (0x0348) /* Timer0_A5 Capture/Compare Control 3 */
DEFCW( TA0CCTL3 , TA0CCTL3_)
Not sure where exactly you do see a problem - maybe you can give me some more background?
Почему мне говорят, что я для побайтного доступа должен пользоваться
mov.w а не
mov.b???
Я чего-то не понимаю? Может я не понимаю, что такое побайтный доступ (byte register access). Я так полагал, что могу обратиться как для чтения, так и для записи к любому регистру (речь о перефирийных), независимо от того по четному адресу он расположен или нечетному и к любой части регистра (младшие 8 бит или старшие 8 бит 16 разрядного регистра). Я правильно понимаю термин?
Спасибо.