7 posts / 0 new
Last post
Heminghui
Offline
Last seen:4 years 3 weeks ago
加入:2017-03-09 06:30
J-LINK 烧录 SCLK 和TMS 怎样设为GPIO口

因IO口不够,把SCLK和TMS PIN 用作普通IO驱动指示灯。按IO的设置方法:在void GPIO_reservations(void)内设定 RESERVE_GPIO( GPIO, GPIO_PORT_1, GPIO_PIN_4, PID_GPIO); //G led 和void set_pad_functions(void) 内设定 GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, false); // G LED 为普通GPIO口, 但是设为高电平输出GPIO_SetActive(GPIO_PORT_1, GPIO_PIN_4); 时,P1.4口一直为低电平,是什么原因呢?

Device:
WI_Dialog
Offline
Last seen:1 day 12 hours ago
Staff
加入:2014-01-03 16:21
Hi,

Hi,
Please make sure SYS_CTRL_REG[DEBUGGER_ENABLE] is set to ''0" to configure JTAG pins to GPIO as follows:
SetBits16(SYS_CTRL_REG, DEBUGGER_ENABLE, 0); // close debugger
Regards,

Heminghui
Offline
Last seen:4 years 3 weeks ago
加入:2017-03-09 06:30
非常感你的回复。代码已经是把所有设定SetBits16

非常感你的回复。代码已经是把所有设定SetBits16(SYS_CTRL_REG, DEBUGGER_ENABLE, 0); 关掉所有的debugger ,P1.4口还是无法控制高低电平输出。如果我把P1.4口改为P1.2 可以看到灯闪烁,因此代码是没有问题,还是P1.4的配置问题,请在帮忙看下是否其它地方还需要修改。SDK版本为V_5.150.2。
void timer_callback(void)
{
静态unsigned char国旗= 0;
if(flag)
{
//GPIO_SetPinFunction( GPIO_CON_GLED_PORT, GPIO_CON_GLED_PIN, OUTPUT, PID_GPIO);
//GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, true); // G LED
// GPIO_SetActive(GPIO_PORT_1, GPIO_PIN_2);
GPIO_SetInactive(GPIO_PORT_1, GPIO_PIN_4);
flag=0;
}
else
{
//GPIO_SetPinFunction( GPIO_CON_GLED_PORT, GPIO_CON_GLED_PIN, OUTPUT, PID_GPIO);
// GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, false); // G LED
//GPIO_SetInactive(GPIO_PORT_1, GPIO_PIN_2);
GPIO_SetActive(GPIO_PORT_1, GPIO_PIN_4);
flag=1;
}
}

WI_Dialog
Offline
Last seen:1 day 12 hours ago
Staff
加入:2014-01-03 16:21
Hi,

Hi,

Do you mind to run this modified code to verify the JTAG is disabled correctly ?

void timer_callback(void)
{
静态unsigned char国旗= 0;

if(GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
{
if(flag)
{
GPIO_ConfigurePin(GPIO_PORT_1, GPIO_PIN_2, OUTPUT, PID_GPIO, true);
flag=0;
}
else
{
GPIO_ConfigurePin(GPIO_PORT_1, GPIO_PIN_2, OUTPUT, PID_GPIO, false);
flag=1;
}
}
else
{
if(flag)
{
//GPIO_SetPinFunction( GPIO_CON_GLED_PORT, GPIO_CON_GLED_PIN, OUTPUT, PID_GPIO);
//GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, true); // G LED
// GPIO_SetActive(GPIO_PORT_1, GPIO_PIN_2);
// GPIO_SetInactive(GPIO_PORT_1, GPIO_PIN_4);
GPIO_ConfigurePin(GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, true);
flag=0;
}
else
{
//GPIO_SetPinFunction( GPIO_CON_GLED_PORT, GPIO_CON_GLED_PIN, OUTPUT, PID_GPIO);
// GPIO_ConfigurePin( GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, false); // G LED
//GPIO_SetInactive(GPIO_PORT_1, GPIO_PIN_2);
// GPIO_SetActive(GPIO_PORT_1, GPIO_PIN_4);
GPIO_ConfigurePin(GPIO_PORT_1, GPIO_PIN_4, OUTPUT, PID_GPIO, false);
flag=1;
}
}
}

Thanks and Regards,

Heminghui
Offline
Last seen:4 years 3 weeks ago
加入:2017-03-09 06:30
用这段代码,证明JTAG已是关闭。P1.2

用这段代码,证明JTAG已是关闭。P1.2 上的LED不会闪烁,同时 P1.4上的LED也不会闪烁。

WI_Dialog
Offline
Last seen:1 day 12 hours ago
Staff
加入:2014-01-03 16:21
Hi,

Hi,

Don't know how you verify your LED blinking feature. Your issue may due to entering sleep mode that obsolete your soft timer. To confirm this assumption, could you please add a statement as below to re-run your test. This statement is to force the software staying alive.

int main_func(void)
{
.....
// get the allowed sleep mode
// time from rwip_power_down() to WFI() must be kept as short as possible!!
sleep_mode = rwip_power_down();
/* statement added */
if ((sleep_mode == mode_ext_sleep) || (sleep_mode == mode_deep_sleep))
{
sleep_mode = mode_idle;
}
.....
}

Regards,

Heminghui
Offline
Last seen:4 years 3 weeks ago
加入:2017-03-09 06:30
已经试过,和睡眠没有关系。如果我把P1.2和P1

已经试过,和睡眠没有关系。如果我把P1.2和P1.4相互对换一下,是可以看到P1.2上的LED灯闪烁。 是不是底层代码需要更改哪里不?
谢谢~~~