请帮助PIC项目. [英] Please Help with PIC project.

查看:62
本文介绍了请帮助PIC项目.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用PIC16F684和Pickit1 Pic Clite

当输入逻辑电平在RA3上变低时.将RA5引脚拉高约30秒.
关闭RA5等待大约10秒钟.打开RA2大约30秒钟,然后关闭RA2,然后等待
在RA3上输入以再次运行.

请帮助.

Using a PIC16F684 and a Pickit1 Pic c lite

When an input logic level go''s low on RA3. Make pin RA5 high for about 30 sec.
Turn off RA5 Wait about 10 sec. Turn on RA2 for about 30 sec then turn off RA2, then wait for the
input on RA3 to Run again.

PLEASE HELP.

推荐答案

我们不为您做作业(请阅读常见问题解答).
您应该尝试自己开发,并在遇到困难时在此处发布特定问题.
We don''t do homework for you (please read the FAQ).
You should try yoursel developing and post here specific questions when you''re stuck.


我从没与pic一起工作过,但这里有些烦人.
它不是100%完成的...我遗漏了一两件事,还没有经过测试.
您必须自己提供时间机制,因为我不知道您使用了什么功能
为了那个原因.我不知道RA的大小,因此我以简短为例.

I''ve never worked with pic but here is something off the top of my head.
Its not 100% complete... I left out one or two things and it hasn''t been tested.
You have to provide the time mechanism yourself as I don''t know what functions you use
for that. I don''t know the size of RA so I used short as an example.

#define RA1 (0x1)
#define RA2 (0x2)
#define RA3 (0x4)
#define RA4 (0x8)
#define RA5 (0x10)
#define RA6 (0x20)
#define RA7 (0x40)

#define LOW (0)
#define HIGH (1)
#define 30_SECONDS (30)
#define 10_SECONDS (10)

typedef union
{
  unsinged short int data;
  
  struct
  {
    unsigned short int RA1        :1; /* Bit <0> */
    unsigned short int RA2        :1; /* Bit <1> */
    unsigned short int RA3        :1; /* Bit <2> */
    unsigned short int RA4        :1; /* Bit <3> */
    unsigned short int RA5        :1; /* Bit <4> */
    unsigned short int RA6        :1; /* Bit <5> */
    unsigned short int RA7        :1; /* Bit <6> */
    unsigned short int RA8        :1; /* Bit <7> */
    unsigned short int RA9        :1; /* Bit <8> */
    unsigned short int RA10       :1; /* Bit <9> */
    unsigned short int RA11       :1; /* Bit <10> */
    unsigned short int RA12       :1; /* Bit <11> */
    unsigned short int RA13       :1; /* Bit <12> */
    unsigned short int RA14       :1; /* Bit <13> */
    unsigned short int RA15       :1; /* Bit <14> */
    unsigned short int RA16       :1; /* Bit <15> */
  } fields;
} RA_UNION;

public void TheFunction()
{
  RA_UNION myRA_UNION;
  if ((myRA_UNION.data & R3) == 0)
  {
    int delay = 0;

    for (delay = 0; delay < 30_SECONDS; delay++)
    {
      /* Make R5 high */
      myRA_UNION.fields.R5 = HIGH;
    }

    myRA_UNION.fields.R5 = LOW;

    for (delay = 0; delay < 10_SECONDS; delay++)
    {
      /* wait for 10 secs */
    }

    for (delay = 0; delay < 30_SECONDS; delay++)
    {
      /* Make R2 high */
      myRA_UNION.fields.R2 = HIGH;
    }

    /* Turn off R2 */
    myRA_UNION.fields.R2 = LOW;
  }

  return;
}

int main()
{
  int i = 0;
  do
  {
    /* loop forever */
    TheFunction()
  } while (i == 0)
  return 0;
}


这篇关于请帮助PIC项目.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆