MSP430菜鸟求助
本帖最后由 yan.ch.ao 于 2013-9-14 22:14 编辑我就是想驱动1.7引脚变低不知道为什么没灵,刚刚学习430没几天,有会的帮忙看看问题持在哪里?谢谢。
谢谢,问题找到了,查错引脚了。谢谢(编辑原因的,结贴,谢谢楼下)
#include "msp430x23x.h"
void Delay(unsigned int n);
main()
{
unsigned int i;
__disable_interrupt();
WDTCTL = WDTPW + WDTHOLD; //Disable WDT.
for(i=0;i<40;i++)
{
Delay(5000);
}
IFG1 &= ~WDTIFG; //PUC.WDT security key error or the expiration of the selected timer interval.
/*
BCSCTL1 &= ~XT2OFF; //polling on the 8M crystal.
IFG1 &= ~OFIFG;
delay(200);
while(IFG1 & OFIFG)
{
IFG1 &= ~OFIFG;
delay(200);
}
BCSCTL2 = SELM_2 + SELS + DIVS_3; //Select XT2 as clock source for MCLK & SMCLK, SMCLK-1M.
*/
//////////DCOCTL = DCO0 + DCO1 + DCO2;
//BCSCTL1 = RSEL0 + RSEL1 + RSEL2;
///////////// BCSCTL1 = RSEL3 + RSEL1;//这么设置后主时钟大约是4M 235
///////////////BCSCTL2 = SELM_0 + DIVS_3;
///DCOCTL = DCO0 + DCO1 + DCO2;
//BCSCTL1 = RSEL0 + RSEL1 + RSEL2;
//BCSCTL2 = SELM_0 + DIVS_2;
P1SEL=0x00;
P1OUT&=0x7f;
P1DIR|=0x80;//p1.7,sda
//P1DIR|=0x80;//p1.7,sda
//P1OUT&=0x80;
while(1)
{
P1SEL=0x00;
P1OUT&=0x7f;
P1DIR|=0x80;//p1.7,sda
//P1REN&=0x7f;
}
}
void Delay(unsigned int n)
{
unsigned inti;
for (i=0; i<n; i++) {;}
} P1.7置高P1OUT|=BIT7;
置低P1OUT&=~BIT7;
还有P1SEL=0x00和P1DIR|=0x80不应该写在while(1)的循环中。 低级问题一堆。。。。。。。
//******************************************************************************
//MSP430x2xx Demo - Software Toggle P1.0
//
//Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.
//ACLK = n/a, MCLK = SMCLK = default DCO
//
// MSP430x2xx
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P1.0|-->LED
//
//A. Dannenberg
//Texas Instruments, Inc
//January 2006
//Built with IAR Embedded Workbench Version: 3.40A
//Active. leo
//2013.08.30
//******************************************************************************
#include "msp430.h"
#include "system.h"
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
Bit_struct.bit0 = 1;
for (;;)
{
volatile unsigned int i; // volatile to prevent optimization
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
i = 10000; // SW Delay
do i--;
while (i != 0);
}
}
activeleo 发表于 2013-9-14 17:01 static/image/common/back.gif
低级问题一堆。。。。。。。
//*********************************************************************** ...
谢谢,问题找到了,查错引脚了。谢谢 dalarang 发表于 2013-9-14 16:33 static/image/common/back.gif
P1.7置高P1OUT|=BIT7;
置低P1OUT&=~BIT7;
谢谢,问题找到了,查错引脚了。谢谢
页:
[1]