这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 综合技术 » 基础知识 » alley,aq430 请教alley,aq430环境的数组定义赋值?

共2条 1/1 1 跳转至

alley,aq430 请教alley,aq430环境的数组定义赋值?

院士
2006-09-17 18:14:16     打赏
alley,aq430 请教alley,aq430环境的数组定义赋值?



关键词: alley     aq430     请教     环境     数组     定义         

院士
2006-12-22 22:43:00     打赏
2楼
问 使用MSP430f413单片机,为什么仿真时(复位时),数组aa中的值不是我设定的值?使用环境aq430,iar没有此现象.
#include <MSP430x41x.h>
unsigned char aa[3]={0x11,0x22,0x33};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
aa[0]=aa[1]+aa[2];
} 1: peipei你好,我用下面的代码做测试,多次上电都正常的。

#include <MSP430xe42x.h>

#define SEG_a 0x10
#define SEG_b 0x20
#define SEG_c 0x40
#define SEG_d 0x08
#define SEG_e 0x04
#define SEG_f 0x01
#define SEG_g 0x02
#define SEG_h 0x80

#define CHAR_SPACE 0
#define CHAR_ALL (SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g|SEG_h)
#define CHAR_0 (SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f)
#define CHAR_1 (SEG_b|SEG_c)
#define CHAR_2 (SEG_a|SEG_b|SEG_d|SEG_e|SEG_g)
#define CHAR_3 (SEG_a|SEG_b|SEG_c|SEG_d|SEG_g)
#define CHAR_4 (SEG_b|SEG_c|SEG_f|SEG_g)
#define CHAR_5 (SEG_a|SEG_c|SEG_d|SEG_f|SEG_g)
#define CHAR_6 (SEG_a|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g)
#define CHAR_7 (SEG_a|SEG_b|SEG_c)
#define CHAR_8 (SEG_a|SEG_b|SEG_c|SEG_d|SEG_e|SEG_f|SEG_g)
#define CHAR_9 (SEG_a|SEG_b|SEG_c|SEG_d|SEG_f|SEG_g)
#define CHAR_A (SEG_a|SEG_b|SEG_c|SEG_e|SEG_f|SEG_g)
#define CHAR_B (SEG_c|SEG_d|SEG_e|SEG_f|SEG_g)
#define CHAR_C (SEG_a|SEG_d|SEG_e|SEG_f)
#define CHAR_D (SEG_b|SEG_c|SEG_d|SEG_e|SEG_g)
#define CHAR_E (SEG_a|SEG_d|SEG_e|SEG_f|SEG_g)
#define CHAR_F (SEG_a|SEG_e|SEG_f|SEG_g)

const unsigned char lcd_digit_table[] =
{
CHAR_0,
CHAR_1,
CHAR_2,
CHAR_3,
CHAR_4,
CHAR_5,
CHAR_6,
CHAR_7,
CHAR_8,
CHAR_9,
CHAR_A,
CHAR_B,
CHAR_C,
CHAR_D,
CHAR_E,
CHAR_F
};

void update_disp(void)
{
unsigned char bcd[3] = {0x12,0x34,0x56};

LCDMEM[ 2] = lcd_digit_table[bcd[0]>>4];
LCDMEM[ 3] = lcd_digit_table[bcd[0]&0x0F];
LCDMEM[ 4] = lcd_digit_table[bcd[1]>>4];
LCDMEM[ 5] = lcd_digit_table[bcd[1]&0x0F];
LCDMEM[ 6] = lcd_digit_table[bcd[2]>>4];
LCDMEM[ 7] = lcd_digit_table[bcd[2]&0x0F];
}


void main (void)
{
unsigned int sec_counter;
WDTCTL = WDTPW + WDTHOLD;

LCDCTL = 0x03D; // 4mux LCD, segs16-23 = outputs
/* 设置中断频率为 1s, 液晶时钟原32分频 */
BTCTL = BT_fLCD_DIV32 | BT_fCLK2_DIV128 | BT_fCLK2_ACLK_DIV256;

while(1)
{

update_disp();
for(sec_counter=0;sec_counter<20000;sec_counter++)
;
}
}

共2条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]