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\u projects/proximity/reporter\u fe中有一个示例/

我认为,由于GPIO多路复用,您可以非常自由地选择UART的引脚配置。请参阅文件periph\u setup.c(在µVision的项目视图中的arch文件夹中),其中包含GPIO\u ConfigurePin函数。在上述引脚配置中,还必须保留IO(在开发时)。这是用RESERVE\u GPIO宏完成的。

敬你,维萨

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

Hello Vesa,
谢谢你的消息。
我的疑问是,任何端口上的任何管脚都可以用作UART管脚吗?我对SPI也有同样的怀疑?
P1\ U 0、P1\ U 1、P1\ U 2引脚是否可以使用串行时钟、串行数据、串行芯片选择引脚?

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
城市轨道交通不输出。要发送的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\ U CLK DO输入/输出。SPI时钟。映射到Px端口
SPI_DI DI INPUT. SPI Data input. Mapped on Px ports
SPI\u DO输出。SPI数据输出。映射到Px端口
SPI_EN DI INPUT. SPI Clock enable. Mapped on Px ports

有关其他管脚映射,请参见数据表。注意,模拟接口使用固定映射。

谢谢!

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位的寄存器数据大小。如何在这种情况下传输数据。

谢谢
苏贾尼亚,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\u t write\u buf[]={0x01、0x02、0x03};
const int chunk_size = 24/8;
int c = 0;
while(c<块大小)
{
SetWord16(SPI_RX_TX_REG0, *write_buf++); // Write to the device, increment after
做{
}while(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.
幸运的是,我使用的芯片,它不允许读取操作,即没有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 ,

我有一个包含3个不同控制寄存器的从机,
根据我的SPI从设备数据表,在每次SPI\ U写入操作之后,我需要等待10秒,然后再进行一次SPI\ U写入:
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
你好,阿斯梅塔,

你好,阿斯梅塔,

你可以使用内核定时器。

  1. Create a new应用程序消息键入文件app_api.h描述你的时间,例如。,APP_EVENT_TIMER.
  2. Create a handler function for the timer. The type of the handler function isint timer\u handler(ke\u msg\u id\u t const msgid,void const*param,ke\u task\u id\u t const dest\u id,ke\u task\u id\u t const src\u 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\u EVENT\u TIMER,(ke\u msg\u func\t)APP\u EVENT\u TIMER\u 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\u 0\DA14580\u DSPS\u 3.150.2\dk\u apps\src\plf\refip\src\driver\timer的DSPS\u 0示例中,有一个timer.h文件,我们可以直接使用这些函数来生成微秒延迟。

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
上师 Master
加入:2014-06-26 08:49
你好,阿斯梅塔,

你好,阿斯梅塔,

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.

在以下示例中的一个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
我有一个while(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)

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

你知道如何实现上述逻辑吗?

谢谢,
asmaitha

VesaN
Offline
Last seen:5年4个月前
上师 Master
加入:2014-06-26 08:49
你好,阿斯梅塔,

你好,阿斯梅塔,

你说的多线程到底是什么意思?无论如何,我想这是一个操作系统的问题。。

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.
I have a key 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\启用IRQ(GPIO\端口\ 0,GPIO\引脚\ 7,GPIO0\ IRQn,1,1,10);

在我的回电中:

void keysweep_callback(void)
{

if(Key_sweep_status==1)
键\扫描\状态=0;
else
键\扫描\状态=1;
}

Inside my while(1)
{
if(键\扫描\状态==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