主题中讨论的其他器件:MSP-FET430UIF、
你(们)好。
有问题让我困扰了好几天。
当我使用 MSP-FET430UIF 使用计时器 B 调试 msp430f5438A 板时、我发现一切都很好。 但是、在我将代码下载到芯片中后、我发现我似乎无法进入计时器 B ISR。 部分代码如下所示。
/*
* this is my initializing function
*/
#define Init_TimerB() \
do{ \
P4SEL |= BIT1; /*P4.1 option select*/ \
P4DIR |= BIT1; /*P4.1 outputs*/ \
P4DS |= BIT1; /*P4.1 full drive strength, it seems it is not necessary*/ \
TBCCR0 = TBCCR0_INIT - 1; \
TBCCTL0 = CCIE; /*enable CCR0 interrupt*/ \
TBCCTL1 = 0x0200 | OUTMOD_4; /*TBxCLn loads when TBxR counts to 0*/ \
TBCCR1 = TBCCR1_NORMAL; \
TBCTL = TBSSEL_2 + MC_3 + TBCLR + TBIE; /*SMCLK, up/down mode, clear TBR, enable TBIFG*/ \
}while(0);
/*
* this is my main function
*/
int main(void) {
STOP_WDT(); // Stop watchdog timer
Init_Port(); // had better to be the 2nd
Init_MAX_Clock(); // For simulator debugging, please comment this line
Init_4keys_keyboard();
Init_driver_EN();
Init_Relay_Protection();
Init_ADC();
Init_My_Nokia_5110();
My_LCD_write_cmd(0x40);
My_LCD_write_cmd(0x80);
__delay_cycles(DELAY_CYCLES_BETWEEN_CMD_AND_DATA);
My_LCD_write_string(Set_voltage);
My_LCD_write_cmd(0x41);
My_LCD_write_cmd(0x80);
__delay_cycles(DELAY_CYCLES_BETWEEN_CMD_AND_DATA);
My_LCD_write_string(Real_voltage);
Wait_for_USCI_A0_TX_buffer_ready(); // Wait for USCI A0 X buffer ready
UCA0TXBUF = 0x00;
// about LED
P10DIR |= 0x0F;
P10OUT &= ~0x0F;
Init_TimerB();
__EINT(); // my macro: #define __EINT() __enable_interrupt()
for(;;) {
LED3_ON(); // for test
if(Display_data_changed){
Update_LCD_num_content();
LCD_display_update();
Display_data_changed = 0;
LED1_ON();
//__NOP(); // for debugging
}
}
}
/*
* Timer B ISR
*/
// Timer B0 interrupt service routine
#pragma vector = TIMERB0_VECTOR
__interrupt void TIMERB0_ISR(void){
LED2_ON(); // for test
ADC_Sample_times++;
if(ADC_Sample_times <= Num_of_Results){
Start_ADC12();
ADC_RESULT_OBTAINED_FLAG = 1;
}
if(ADC_Sample_times == 25){ // 20 changed to 40
ADC_Sample_times = 0;
}
}
// Timer_B1 Interrupt Vector (TBIV) handler
#pragma vector=TIMERB1_VECTOR
__interrupt void TIMERB1_ISR(void)
{
/* Any access, read or write, of the TBIV register automatically resets the
highest "pending" interrupt flag. */
switch( __even_in_range(TBIV,14) )
{
case 14:
if(ADC_RESULT_OBTAINED_FLAG){
PERMMIT_GET_ADC_DATA(); // overflow
}
break;
case 0: break; // No interrupt
case 2: break; // CCR1 not used
case 4: break; // CCR2 not used
case 6: break; // CCR3 not used
case 8: break; // CCR4 not used
case 10: break; // CCR5 not used
case 12: break; // CCR6 not used
default: break;
}
}
当我使用 MSP-FET430UIF 调试代码时、我发现 LED3和 LED2都可以亮起。 但是、在我将代码下载到芯片中并在硬件中重置芯片后、我发现 LED2无法正常工作。 我可以确认所有 LED 未损坏。 因此、我似乎没有进入 Timer B ISR、这看起来很奇怪。 我已经不能被压碎了。 如果有人能帮助我,我会非常感激。
可以在 My GitHub 代表(https://github.com/eexu/27_Parallel_Operation_of_Two_Buck)上看到整个项目