neuron c 显式报文发送求救! 点击:448 | 回复:1



Mac.

    
  • 精华:0帖
  • 求助:0帖
  • 帖子:6帖 | 8回
  • 年度积分:0
  • 历史总积分:26
  • 注册:2005年3月23日
发表于:2007-10-24 20:31:00
楼主
我用PL3120/PL3150的MiniEVK学习neuron C,编写了一个小的显式报文的发送程序.按照书上写的,调用msg_send()后, 有msg_succeed事件发生, 但是却没有实际的信号上到电力线上, 请帮我看看有什么问题?

#include <isi.h>
#include <mem.h>
#include <stdlib.h>
#include <control.h>
#include <snvt_cfg.h>

#pragma num_alias_table_entries  4
#pragma num_addr_table_entries  5
#pragma enable_io_pullups
#pragma codegen optimization_on
#pragma codegen cp_family_space_optimization
#pragma set_node_sd_string  "MGLight"


IO_4 input bitshift numbits(8) clockedge(-) ioButtons;
IO_6 output bit ioButtonLd = 1;

#define MG_BUTTONS_DEBOUNCE 3
unsigned GetButtons(void) {
    unsigned Buttons, Index;
    Buttons = 0xFFu;
    for(Index = 0; Index < MG_BUTTONS_DEBOUNCE; ++Index) {
        // capture parallel lines:
        io_out(ioButtonLd, 0);
        io_out(ioButtonLd, 1);
        // take a sample and debounce:
        Buttons &= (unsigned)io_in(ioButtons);
    }
    return ~Buttons;
}

IO_2 output bitshift numbits(8) ioLEDs;
IO_1 output bit ioLEDLd = 1;

unsigned PreviousLEDs = 0;
void SetLEDs(unsigned LEDs, unsigned Mask) {
    // We may only want to set some LEDs, indicated by Mask. Bits outside the
    // mask are added from the previous pattern:
    LEDs |= PreviousLEDs & ~Mask;
    PreviousLEDs = LEDs;

    // LEDs are driven active low - the SetLEDs function handles the inversion
    // so that the application developer may think in positive logic:
    io_out(ioLEDs, ~LEDs);
    // strobe:
    io_out(ioLEDLd, 0);
    io_out(ioLEDLd, 1);
}

when(reset)
{
    SetLEDs(0x00, 0xFFu);   // LEDs into defined state
}

mtimer repeating kbTick = 50ul;
unsigned Previous = 0;
unsigned LED = 0;

msg_tag bind_info(nonbind) tag_out;

when(timer_expires(kbTick))
{
    unsigned Buttons;
    Buttons = GetButtons();
    if(Previous!=Buttons)
    {
        Previous = Buttons;
        LED = LED^Buttons;
        SetLEDs(LED,0xFF);
        msg_out.tag = tag_out;
        msg_out.code = LED;
        msg_send();
    }
    /*else
    {
        SetLEDs(LE



Mac.

  • 精华:0帖
  • 求助:0帖
  • 帖子:6帖 | 8回
  • 年度积分:0
  • 历史总积分:26
  • 注册:2005年3月23日
发表于:2007-10-24 20:34:00
1楼
我的意图是: 按下MiniGizmo板子上的随便一个按键, 就发一个包出去, 如果发送成功了,就所有的灯亮, 不成功, 就灯灭. 现在msg_succeeds的事件也响应了. 但是按完后TXON的灯不闪, 用示波器也看不见信号出去. 请问是怎么回事呢?

热门招聘
相关主题

官方公众号

智造工程师