UART configuration.

16 posts / 0 new
Last post
asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
UART configuration.

Hello,
I am using DA14580 , now i want to connect my DA14580 with another microcontroller on UART interface, which port pins can be used? Also my DA14580 is using I2C-EEPROM.

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
Hello,

Hello,
我没有使用外部处理器配置的DA1458x,但是/ keil_Projects / proximity / eporter_fe /中有和示例

我认为您可以通过GPIO多路复用来选择UART的引脚配置。请参阅文件periph_setup.cn(在μVision的项目视图中的Arch文件夹中)您有GPIO_CONFIGUREPIN函数。以上引脚配置,您还必须保留IO(开发时)。这是通过Letail_GPIO宏完成的。

最好的问候,vesa

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello Vesa,

Hello Vesa,
谢谢你的信息。
我的怀疑是,任何端口上的任何PIN可以用作UART引脚吗?我也对SPI同样怀疑吗?
P1_0,P1_1,P1_2引脚可以EB使用串行CLK,串行数据,串行芯片选择引脚?

Is there any document which describes what different functionalities each pin can support?

谢谢
asm

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
According to the datasheet

根据数据表,您可以在任何端口上使用UART(http://support.dialog-semiconductor.com/resource/da14580-datasheet, page 7)

UTX DO OUTPUT. UART transmit data. Mapped on Px ports
URX DI INPUT. UART receive data. Mapped on Px ports
urts进行输出。UART请求发送。映射到PX端口
UCTS DI INPUT. UART Clear to Send. Mapped on Px ports
UTX2 DO OUTPUT. UART 2 transmit data. Mapped on Px ports
URX2 DI INPUT. UART 2 receive data. Mapped on Px ports
URTS2 DO OUTPUT. UART 2 Request to Send. Mapped on Px ports
UCTS2 DI INPUT. UART 2 Clear to Send. Mapped on Px ports

Same applies to the SPI bus

SPI_CLK进行输入/输出。SPI时钟。映射到PX端口
SPI_DI DI INPUT. SPI Data input. Mapped on Px ports
SPI_DO进行输出。SPI数据输出。映射到PX端口
SPI_EN DI INPUT. SPI Clock enable. Mapped on Px ports

查看其他PIN映射的数据表。请注意,模拟接口使用固定映射。

谢谢!

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello Vesa,

Hello Vesa,
谢谢a lot.
Now I understood that any of the Px pins can be configured as SPI interface pins, provided we initialize the pins appropriately in periph_setup.h file.
但根据DA14580数据表SPI仅支持8/16/32位模式传输,但我的从站的寄存器数据尺寸为24位。在此方案中传输数据。

谢谢
soujanya.k.

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
Hi Soujanya.K,

Hi Soujanya.K,

then I guess you could just use 8-bit mode:

SetBits16(SPI_CTRL_REG, SPI_WORD, SPI_MODE_8BIT); // set to 8bit mode

And do reading/writing operation in chunks of three 8-bit blocks:

uint8_t write_buf [] = {0x01,0x02,0x03};
const int chunk_size = 24/8;
int c = 0;
而(c {
SetWord16(SPI_RX_TX_REG0, *write_buf++); // Write to the device, increment after
做{
} whiled(getBits16(spi_ctrl_reg,spi_int_bit)== 0);//虽然RX寄存器为空

SetWord16(SPI_CLEAR_INT_REG, 1); // Clear SPI_INT_BIT
c++; // Increment c
}

Something like that, I haven't tested it!!

PS. If you want to read at the same time you need to do something like this read_buf = GetWord16(SPI_RX_TX_REG0) & 0xff; masking with 0xff just in case to make sure no unwanted data arrives. This method is a bit tricky, you need to play with the buffer... I never encountered a device with SPI chunk size of 24-bit

我在短时间内没有提出其他想法

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello Vesa,

Hello Vesa,
谢谢a lot.
幸运的是,我正在使用的芯片不允许读取操作i.e.没有MISO信号。
So I only need to perform SPI_Write operations only.

谢谢
asm

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello ,

Hello ,

我有一个包含3Differ控制寄存器的从站,
根据我的SPI从设备数据表在每个SPI_WRITE操作之后,我需要在我做一个SPI_WRITE之前等待10MSEC:
spi_write(register1, data);
delay(10msec);
spi_write(register2, data);
delay(10msec);

How can I introduce this delay of 10msec?

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
asmatha你好,

asmatha你好,

您可以使用内核定时器。

  1. Create a newapp_msg.输入文件app_api.h描述你的时间,例如,APP_EVENT_TIMER
  2. Create a handler function for the timer. The type of the handler function isint timer_handler(ke_msg_id_t const msgid,void const * param,ke_task_id_t const dest_id,ke_task_id_t const src_id)。Add the function definition to the header file too! This function must be visible to fileapp_task_handlers.h
  3. In fileapp_task_handlers.h, add the created handler function to the timer:{app_event_timer,(ke_msg_func_t)app_event_timer_handler}。如果需要,请添加特定配置文件包括条件。
  • Use functionke_timer_set设置计时器。
  • To clear a timer, useke_timer_clear

注意:这是内核计时器,它有点不准确,但我想应该工作。至少,您可以先尝试一下。

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello Vesa,

Hello Vesa,
谢谢a lot for your help.

I am really sorry but I an understand how to define and invoke timer_handler in my spi driver file.
Kindly request you to direct me with some implemented examples.

在DSPS_0示例中的位置 - > DSPS_0 \ DA14580_DSPS_3.150.2 \ DK_APPS \ SRC \ PLF \ RECIP \ SRC \ DREVER \ TIMER中,有一个TIMER.H文件我们可以直接使用这些函数来生成微秒延迟。

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
asmatha你好,

asmatha你好,

yes, it seems you can use thetimer_waitfunction to wait for max 1000µs, or 1ms.

You need to define the handler function in the header file and then include it in your spi driver.

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello Vesa,

Hello Vesa,
谢谢for your information.

在Peripheral_examples中的一个SDK示例中:
I found that
for(I=00;i<20;i++) ; this loop introduces a delay of 7.6miccro secs
所以我们可以使用这个循环延迟吗?

建议使用此逻辑吗?

谢谢
asmaitha

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
Hi asmaitha,

Hi asmaitha,

if you need a very short delay, then yes, I think it is a OK to use that.

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello VesaN,

Hello VesaN,
谢谢I tested for a delay upto 10sec, its not so accurate.
I was interested to know if BLE DA14580 supports multi-threading concept?
My scenario is that
我有一段时间(1)循环运行,我正在GPIO上注册IRQ(对于一个关键新闻事件),
So whenever key is pressed if while(1) is executing then we should break out from THIS while loop and vice-versa(i.e. for next keypress again while(1) should start executing)

但我观察到的是,由于(1)循环,我的中断不会被执行。

任何想法如何实现上述逻辑?

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
asmatha你好,

asmatha你好,

多线程究竟是什么意思?在任何情况下,我想这是一个操作系统的问题..

GPIO interrupt should work even you are in an while(1) {} loop, if you have configured them right.

I think you shouldn't use while(1) loop like that if you are using the SDK. Most definitely the loop will break it and you will encounter some strange issues.

What are you trying to achieve with the button press? Maybe we can find a better solution than while loop

asmaitha
Offline
Last seen:5 years 1 week ago
Expert
加入:2014-11-20 08:45
Hello VesaN,

Hello VesaN,
I have a while(1) loop which keeps on writing specific data over SPI to my slave device.
我有一个关键on P0_7 , so when I press the key it goes low with a debounce period of 10msec thereby generating an interrupt.
i am registering the interrupt as :
GPIO_RegisterCallback(GPIO0_IRQn, keysweep_callback);
gpio_enableirq(gpio_port_0,gpio_pin_7,gpio0_irqn,1,1,10);

在我的回调中:

void keysweep_callback(void)
{

if(Key_sweep_status==1)
key_sweep_status = 0;
else
key_sweep_status = 1;
}

Inside my while(1)
{
if(key_sweep_status == 1)
/*do the concerned action*/
else
break;
}

But what i am encountering is that once control goes into while(1) loop, even i press the key "keysweep_callback" is not getting invoked.

谢谢,
asmaitha