共2条
1/1 1 跳转至页
alley,aq430 请教alley,aq430环境的数组定义赋值?
问
使用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++)
;
}
}
#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 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
vscode+cmake搭建雅特力AT32L021开发环境被打赏30分 | |
【换取逻辑分析仪】自制底板并驱动ArduinoNanoRP2040ConnectLCD扩展板被打赏47分 | |
【分享评测,赢取加热台】RISC-V GCC 内嵌汇编使用被打赏38分 | |
【换取逻辑分析仪】-基于ADI单片机MAX78000的简易MP3音乐播放器被打赏48分 | |
我想要一部加热台+树莓派PICO驱动AHT10被打赏38分 | |
【换取逻辑分析仪】-硬件SPI驱动OLED屏幕被打赏36分 | |
换逻辑分析仪+上下拉与多路选择器被打赏29分 | |
Let'sdo第3期任务合集被打赏50分 | |
换逻辑分析仪+Verilog三态门被打赏27分 | |
换逻辑分析仪+Verilog多输出门被打赏24分 |