小编Fid*_*its的帖子

什么是与LPC1788微控制器一起使用的优秀RTOS?

我正试图找到一个免费/廉价的RTOS,其他人发现它与恩智浦LPC1788微控制器配合得很好.我原本打算使用FreeRTOS,但它似乎不支持那个特定的处理器; 最接近的支持核心是LPC1768.ThreadX可与LPC1788配合使用,但它的许可证将耗资数千英镑.建议?

编辑1:我忘了提及,我正在使用IAR Embedded Workbench.

编辑2:我想我还应该指出,我对嵌入式编程相当新,更不用说使用RTOS了.FreeRTOS和ThreadX似乎非常相似,都有相当直观的API.另一个RTOS的API与这些API的匹配越多,我想就越好.

编辑3:我一直在寻找一个名为embOS的RTOS.它看起来很专业,API看起来不错,它们支持相当数量的处理器/ IDE组合(包括我的),而且我已经有一个示例项目正常工作.它不是免费的,它的许可证将花费大约2500欧元,但这仍然比threadX许可证便宜约3倍.感谢您的建议,我觉得有点不好,我不能选择一个接受的答案.

c microcontroller rtos lpc threadx

4
推荐指数
2
解决办法
5866
查看次数

从两个不同的进程访问时,为什么共享内存值会发生变化?

我在父母和孩子之间创建共享内存.然后我从子进程向共享内存写一个值并从父进程中读取它.但价值观是不同的.这是代码:

#include <sys/shm.h>
#include <sys/stat.h>
#include <stdio.h>

int main()
{
    int seg_id, pid;
    int fib1 = 1, fib = 1, temp;
    int i, tempsize;
    int *result;

    seg_id = shmget(IPC_PRIVATE, 8, S_IRUSR | S_IWUSR);
    result = (int *) shmat(seg_id, NULL, 0);

    printf("Enter size\n> ");
    scanf("%d", &tempsize);

    pid = fork();
    if (pid == 0) 
    {
         for(i = 0; i < tempsize; i++)
         {
             temp = fib;
             fib = fib + fib1;
             fib1 = temp;
         }
         printf("fib value %d\n", fib);

         result = fib; …
Run Code Online (Sandbox Code Playgroud)

c pointers shared-memory

3
推荐指数
1
解决办法
776
查看次数

从C中的另一个函数调用main函数

我有一个main函数,它在初始化期间运行一些函数,然后运行一个while循环,等待来自UART的命令.

当我看到一个特定的命令(让我们说重置)时,我调用一个返回值的函数.我想做以下事情:

  1. 保存返回的值
  2. 使用返回的值再次启动main函数.在main中的函数初始化期间需要返回值.

我是C的新手,我无法想出一种在main中保存变量值的方法.

c program-entry-point function call

3
推荐指数
1
解决办法
3052
查看次数

在C中修改函数中的数组

#include <stdio.h>
#include <stdlib.h>

void array_tester(int *array);

int main(int argc,char *argv[])
{   
    int test[] = {1,1,1,1};
    int print;
    for(print = 0; print < sizeof(test) / sizeof(int); print++)
    {
        printf("%d\n",test[print] );
    }

    array_tester(test);
    for(print = 0;print < sizeof(test)/sizeof(int);print++)
    {
        printf("%d\n",test[print] );
    }

    return EXIT_SUCCESS;
}


void array_tester(int array[])
{   
    int i ;
    for(i = 0; i < sizeof(array) / sizeof(int); i++)
    {
        array[i] = i;
    } 
}
Run Code Online (Sandbox Code Playgroud)

问题是我想修改array_tester函数中的数组但我无法这样做.我在里面用sizeof()什么?

c

2
推荐指数
1
解决办法
92
查看次数

有人可以向我解释这段代码的作用吗?

这实际上是考试中的一个问题,我不太明白 typedef 的作用,如果有人能解释一下,我将不胜感激。

typedef int (*funcptr_t)(int);

int myfoo(int i) {
   printf("%d\n", i + 1);
   return i;
}

funcptr_t foo(int i) {
   printf("%d\n", i + 1);
   return myfoo;
}

int main() {
   funcptr_t fooptr = foo(0);
   fooptr(10);
   printf("%p %p\n", fooptr, myfoo);
   return 0;
}
Run Code Online (Sandbox Code Playgroud)

c c++

2
推荐指数
1
解决办法
213
查看次数

十进制到任何基数<17 calulator c ++

我的任务是将十进制数转换为基数p.p由用户输入.到目前为止这是我的代码:

for(int i = 0; i < 100; i++)
{
    if(a % p == 0)  nn[i] = '0';
    if(a % p == 1)  nn[i] = '1';
    if(a % p == 2)  nn[i] = '2';
    if(a % p == 3)  nn[i] = '3';
    if(a % p == 4)  nn[i] = '4';
    if(a % p == 5)  nn[i] = '5';
    if(a % p == 6)  nn[i] = '6';
    if(a % p == 7)  nn[i] = '7';
    if(a % …
Run Code Online (Sandbox Code Playgroud)

c++ binary decimal calculator

1
推荐指数
1
解决办法
151
查看次数

这个程序的逻辑是什么?

我在书中遇到了一个问题,它要求我写出以下程序的输出.

#include<stdio.h>

int main()
{
     int j=4;
     ( !j != 1 ? printf("\nWelcome") : printf("GooD Bye"));
     return 0;
}
Run Code Online (Sandbox Code Playgroud)

我基本上无法理解在运行程序时如何打印Welcome.任何人都可以在运算符层次结构的帮助下解释,编译器根据表达式计算出什么值?

c

1
推荐指数
1
解决办法
182
查看次数

试图在C中学习动态内存分配

我正在尝试学习动态内存分配和结构,我有一些问题.

首先

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int *number;
    number = malloc(1*sizeof(int));
    int a;
    for(a=0;a<150;a++)
    {
        number[a]=a;
        printf("%d ",number[a]);
    }
    return 0;
 }
Run Code Online (Sandbox Code Playgroud)

在这个样本中,我计划给它错误.因为我将它分配给1个整数的大小,然后我写了太多的整数.它不应该给我一个错误吗?你能详细解释一下吗?

struct people 
{
    char *name;
    int age;
    char *personalInfo;
} human[3];
Run Code Online (Sandbox Code Playgroud)

当我定义这样的结构时,如何分配它以保持超过3个人?如何将其更改为人类[20]或更多?如果答案是写人而不是人[3],我应该如何分配?喜欢malloc(number*sizeof(char)*sizeof(int)*sizeof(char))

还有一件事,在第二个例子中,我需要分配名称和个人信息指针吗?

c malloc dynamic-allocation

1
推荐指数
1
解决办法
190
查看次数

如何在C++中写小数点后的2位数?

在C语言中我们可以这样写;

printf("%.2f", number);
Run Code Online (Sandbox Code Playgroud)

我怎么能用C++做到这一点?

std::cout << "The number is " << number;
Run Code Online (Sandbox Code Playgroud)

c c++ floating-point double

1
推荐指数
1
解决办法
3519
查看次数

10的权力

  #include <stdio.h>
  #include <stdlib.h>

  #define SIZEOF(arr) (sizeof(arr) / sizeof(arr[0]))
  #define PrintInt(expr) printf("%s:%d\n",#expr,(expr))

  int main()
  {
      /* The powers of 10 */
      int pot[] = {
          0001,
          0010,
          0100,
          1000
      };
      int i;

      for(i=0;i<SIZEOF(pot);i++)
          PrintInt(pot[i]);
      return 0;
  }
Run Code Online (Sandbox Code Playgroud)

以下代码的输出是

pot [i]:1
pot [i]:8
pot [i]:64
pot [i]:1000

为什么它会给出这样的输出?`

c

1
推荐指数
1
解决办法
219
查看次数