微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > 射频无线通信设计 > Zigbee关于AD采样的问题,急急急!

Zigbee关于AD采样的问题,急急急!

时间:10-02 整理:3721RD 点击:
JN5139外接热电偶测温,怎样读取AD口的数据,求指导

= =没整明白你说的是不知道怎么读取模块的结果的还是模块读取AD的?

需要上协议栈还是仅仅当做MCU用?如果是前一种的话可以参考TI的传感器数据采集工程,对于后一种就是配置AD模式了。如果是单通道采集就是配置ADCON3这个寄存器去配置采样通道,采样频率和参考电压就行了,网上好多例子的。有些问题最好描述清楚,不然都不知道怎么回你。

还有你这个发错了贴了,最好去zigbee板块发。

我帮你转到zigbee板块

这个证需要呢

模块读取ad的

是前一种的,需要外接电路的那种

现在就是不明白程序哪里有问题,外接电路怎么搭

你可以用P0.7来去读取AD值。你这样说谁也不知道什么情况,你要说下到底出了什么问题是无法读取值还是?

读ad口的问题我暂时没有搭外接电路,我发现程序应该有问题,读ad口的程序烧进板子后超级终端没有任何显示

这是coordinator的程序,帮我看下吧,纠结死了
/****************************************************************************
*
* MODULE: WSN - Coordinator
*
* COMPONENT: $RCSfile: WSN_Coordinator.c,v $
*
* VERSION: $Name: $
*
* REVISION: $Revision: 1.7 $
*
* DATED: $Date: 2007/07/12 11:03:03 $
*
* STATUS: $State: Exp $
*
* AUTHOR: IDM
*
* DESCRIPTION:
*
* Implements a Wireless Sensor Network Coordinator Node using Jennic Zigbee
* stack. Receives data from compatible nodes via the radio and retransmits to
* to host using UART.
*
* Update history
* $Log: WSN_Coordinator.c,v $
* Revision 1.7 2007/07/12 11:03:03 ndani
* Add simple descriptor after network has started
*
* Revision 1.6 2007/07/12 10:03:34 ndani
*
*
* LAST MODIFIED BY: $Author: ndani $
* $Modtime: $
*
****************************************************************************
*
* This software is owned by Jennic and/or its supplier and is protected
* under applicable copyright laws. All rights are reserved. We grant You,
* and any third parties, a license to use this software solely and
* exclusively on Jennic products. You, and any third parties must reproduce
* the copyright and warranty notice and any other legend of ownership on each
* copy or partial copy of the software.
*
* THIS SOFTWARE IS PROVIDED "AS IS". JENNIC MAKES NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
* ACCURACY OR LACK OF NEGLIGENCE. JENNIC SHALL NOT, IN ANY CIRCUMSTANCES,
* BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT LIMITED TO, SPECIAL,
* INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY REASON WHATSOEVER.
*
* Copyright Jennic Ltd 2005, 2006, 2007. All rights reserved
*
****************************************************************************/

/****************************************************************************/
/*** Include files ***/
/****************************************************************************/
#include <jendefs.h>
#include <LedControl.h>
#include <AppHardwareApi.h>
#include <Utilities.h>
#include <JZ_Api.h>
#include <gdb.h>
#include "..\..\..\Chip\Common\Include\Printf.h"

#include "WSN_Profile.h"

/****************************************************************************/
/*** Macro Definitions ***/
/****************************************************************************/
/* Timing values */
#define APP_TICK_PERIOD_ms 500

/****************************************************************************/
/*** Type Definitions ***/
/****************************************************************************/

/****************************************************************************/
/*** Local Function Prototypes ***/
/****************************************************************************/
PRIVATE void vInit(void);
PRIVATE void vToggleLed(void *pvMsg, uint8 u8Dummy);
PRIVATE void vTxSerialDataFrame(uint16 u16NodeId,
uint16 u16Humidity,
uint16 u16Temperature,
uint16 u16BattVoltage);

/****************************************************************************/
/*** Exported Variables ***/
/****************************************************************************/

/****************************************************************************/
/*** Local Variables ***/
/****************************************************************************/
PRIVATE bool_t bNwkStarted = FALSE;
PRIVATE bool_t bAppTimerStarted = FALSE;

/****************************************************************************
*
* NAME: AppColdStart
*
* DESCRIPTION:
* Entry point for application from boot loader. Initialises system and runs
* main loop.
*
* RETURNS:
* Never returns.
*
****************************************************************************/
PUBLIC void AppColdStart(void)
{
/* Debug hooks: include these regardless of whether debugging or not */
HAL_GDB_INIT();
HAL_BREAKPOINT();

/* Set network information */
JZS_sConfig.u32Channel = WSN_CHANNEL;
JZS_sConfig.u16PanId = WSN_PAN_ID;

/* General initialisation */
vInit();

/* No return from the above function call */
}

/****************************************************************************
*
* NAME: AppWarmStart
*
* DESCRIPTION:
* Entry point for application from boot loader. Simply jumps to AppColdStart
* as, in this instance, application will never warm start.
*
* RETURNS:
* Never returns.
*
****************************************************************************/
PUBLIC void AppWarmStart(void)
{
AppColdStart();
}

/****************************************************************************/
/*** Local Functions ***/
/****************************************************************************/
/****************************************************************************
*
* NAME: vInit
*
* DESCRIPTION:
* Initialises Zigbee stack and hardware. Final action is to start BOS, from
* which there is no return. Subsequent application actions occur in the
* functions defined above.
*
* RETURNS:
* No return from this function
*
****************************************************************************/
PRIVATE void vInit(void)
{

/* Initialise Zigbee stack */
JZS_u32InitSystem(TRUE);

/* Set DIO for LEDs */
vLedInitFfd();

vLedControl(0,0);
vLedControl(1,0);
vLedControl(2,0);
vLedControl(3,0);

/* Intialise serial comms unless debug mode*/
#ifndef GDB
vUART_printInit();

#endif

/* Start BOS */
(void)bBosRun(TRUE);

/* No return from the above function call */
}

/****************************************************************************
*
* NAME: vTxSerialDataFrame
*
* DESCRIPTION:
* Transmits node data (address and sensor readings) to host via serial port.
*
* PARAMETERS: Name RW Usage
* u16NodeId R Short address of node that generated the data
*
* u16Temperature R Reading from temperature sensor (degrees C)
* u16BattVoltage R ADC reading of supply voltage (mv)
*
****************************************************************************/
PRIVATE void vTxSerialDataFrame(uint16 u16NodeId,
uint16 u16Temperature,
)
{
#ifndef GDB
vPrintf("\n\r\n\rAddress = %x", u16NodeId);
vPrintf("\n\rTemperature = %d", u16Temperature);

#endif
}

/****************************************************************************
*
* NAME: vToggleLed
*
* DESCRIPTION:
* Gets called by a BOS timer. Toggles LED1 to indicate we are alive.
*
****************************************************************************/
PRIVATE void vToggleLed(void *pvMsg, uint8 u8Dummy)
{
uint8 u8Msg;
uint8 u8TimerId;
static bool_t bToggle;

if (bToggle)
{
vLedControl(0,0);
}
else
{
vLedControl(0,1);
}
bToggle = !bToggle;

(void)bBosCreateTimer(vToggleLed, &u8Msg, 0, (APP_TICK_PERIOD_ms / 10), &u8TimerId);
}

/****************************************************************************/
/*** Functions called by the stack ***/
/****************************************************************************/

/****************************************************************************
*
* NAME: JZA_vAppEventHandler
*
* DESCRIPTION:
* Called regularly by the task scheduler. This function reads the hardware
* event queue and processes the events therein. It is important that this
* function exits after a relatively short time so that the other tasks are
* not adversely affected.
*
****************************************************************************/
void JZA_vAppEventHandler(void)
{
uint8 u8Msg;
uint8 u8TimerId;

if (!bAppTimerStarted)
{
if (bNwkStarted)
{
bAppTimerStarted = TRUE;
(void)bBosCreateTimer(vToggleLed, &u8Msg, 0, (APP_TICK_PERIOD_ms / 10), &u8TimerId);
}
}
}

/****************************************************************************
*
* NAME: JZA_vPeripheralEvent
*
* DESCRIPTION:
* Called when a hardware event causes an interrupt. This function is called
* from within the interrupt context so should be brief. In this case, the
* information is placed on a simple FIFO queue to be processed later.
*
* PARAMETERS: Name RW Usage
* u32Device R Peripheral generating interrupt
* u32ItemBitmap R Bitmap of interrupt sources within peripheral
*
****************************************************************************/
PUBLIC void JZA_vPeripheralEvent(uint32 u32Device, uint32 u32ItemBitmap)
{
}

/****************************************************************************
*
* NAME: JZA_vAppDefineTasks
*
* DESCRIPTION:
* Called by Zigbee stack during initialisation to allow the application to
* initialise any tasks that it requires. This application requires none.
*
* RETURNS:
* void
*
****************************************************************************/
PUBLIC void JZA_vAppDefineTasks(void)
{
}

/****************************************************************************
*
* NAME: JZA_boAppStart
*
* DESCRIPTION:
* Called by Zigbee stack during initialisation. Sets up the profile
* information and starts the networking activity
*
* RETURNS:
* TRUE
*
****************************************************************************/
PUBLIC bool_t JZA_boAppStart(void)
{

JZS_vStartStack();

return TRUE;
}

/****************************************************************************
*
* NAME: JZA_eAfKvpObject
*
* DESCRIPTION:
* Called when a KVP transaction has been received with a matching endpoint.
*
* PARAMETERS: Name RW Usage
* afSrcAddr R Address of sender device
* u8DstEndpoint R Endpoint at receiver
* pu8ClusterId R Pointer to cluster ID
* eCommandTypeId R KVP command type
* u16AttributeId R KVP attribute ID
* pu8AfduLength R Pointer to length of data
* pu8Afdu R Data array
*
* RETURNS:
* AF_ERROR_CODE
*
****************************************************************************/
PUBLIC bool_t JZA_bAfKvpObject(APS_Addrmode_e eAddrMode,
uint16 u16AddrSrc,
uint8 u8SrcEP,
uint8 u8LQI,
uint8 u8DstEP,
uint8 u8ClusterId,
uint8 *pu8ClusterIDRsp,
AF_Transaction_s *puTransactionInd,
AF_Transaction_s *puTransactionRsp)
{
return KVP_SUCCESS;
}

/****************************************************************************
*
* NAME: JZA_vAfKvpResponse
*
* DESCRIPTION:
* Called after a KVP transaction with acknowledgement request, when the
* acknowledgement arrives. In this application no action is taken as no
* KVP transaction acknowledgements are expected.
*
* PARAMETERS: Name RW Usage
* srcAddressMod R Address of sender device
* transactionSequenceNum R KVP transaction number
* commandTypeIdentifier R KVP command type
* dstEndPoint R Endpoint at receiver
* clusterID R Cluster ID
* attributeIdentifier R KVP attribute ID
* errorCode R Result code
* afduLength R Length of payload data
* pAfdu R Payload data array
*
****************************************************************************/
PUBLIC void JZA_vAfKvpResponse(APS_Addrmode_e eAddrMode,
uint16 u16AddrSrc,
uint8 u8SrcEP,
uint8 u8LQI,
uint8 u8DstEP,
uint8 u8ClusterID,
AF_Transaction_s *puTransactionInd)
{
}

/****************************************************************************
*
* NAME: JZA_pu8AfMsgObject
*
* DESCRIPTION:
* Called when a MSG transaction has been received with a matching endpoint.
*
* PARAMETERS: Name RW Usage
* afSrcAddr R Address of sender device
* dstEndPoint R Endpoint at receiver
* clusterID R Pointer to cluster ID
* afduLength R Pointer to length of data
* pAfdu R Data array
*
* RETURNS:
* NULL
*
****************************************************************************/
PUBLIC bool_t JZA_bAfMsgObject(APS_Addrmode_e eAddrMode,
uint16 u16AddrSrc,
uint8 u8SrcEP,
uint8 u8LQI,
uint8 u8DstEP,
uint8 u8ClusterID,
uint8 *pu8ClusterIDRsp,
AF_Transaction_s *puTransactionInd,
AF_Transaction_s *puTransactionRsp)
{
uint16 u16BattVoltage;
uint16 u16Temperature;

if ((eAddrMode == APS_ADDRMODE_SHORT) && (u8DstEP == WSN_DATA_SINK_ENDPOINT))
{
if(u8ClusterID == WSN_CID_SENSOR_READINGS)
{
u16BattVoltage = puTransactionInd->uFrame.sMsg.au8TransactionData[1];
u16BattVoltage = u16BattVoltage << 8;
u16BattVoltage |= puTransactionInd->uFrame.sMsg.au8TransactionData[0];

u16Temperature = puTransactionInd->uFrame.sMsg.au8TransactionData[3];
u16Temperature = u16Temperature << 8;
u16Temperature |= puTransactionInd->uFrame.sMsg.au8TransactionData[2];



vTxSerialDataFrame(u16AddrSrc, u16Temperature, u16BattVoltage);
}
}
return 0;
}

/****************************************************************************
*
* NAME: JZA_vZdpResponse

*
* DESCRIPTION:
* Called when a ZDP response frame has been received. In this application no
* action is taken as no ZDP responses are anticipated.
*
* PARAMETERS: Name RW Usage
* u8Type R ZDP response type
* pu8Payload R Payload buffer
* u8PayloadLen R Length of payload
*
****************************************************************************/
PUBLIC void JZA_vZdpResponse(uint8 u8Type,
uint8 u8LQI,
uint8 *pu8Payload,
uint8 u8PayloadLen)
{
}

/****************************************************************************
*
* NAME: JZA_vStackEvent
*
* DESCRIPTION:
* Called by Zigbee stack to pass an event up to the application.
*
* RETURNS:
* TRUE
*
****************************************************************************/
PUBLIC void JZA_vStackEvent(teJZS_EventIdentifier eEventId,
tuJZS_StackEvent *puStackEvent)
if (eEventId == JZS_EVENT_NWK_STARTED)
{

// load the simple descriptor now that the network has started
uint8 u8InputClusterCnt = 1;
uint8 au8InputClusterList[] = {WSN_CID_SENSOR_READINGS};
uint8 u8OutputClusterCnt = 0;
uint8 au8OutputClusterList[] = {};

(void)afmeAddSimpleDesc(WSN_DATA_SINK_ENDPOINT,
WSN_PROFILE_ID,
0x0000,
0x00,
0x00,
u8InputClusterCnt,
au8InputClusterList,
u8OutputClusterCnt,
au8OutputClusterList);

bNwkStarted = TRUE;
}
}

/****************************************************************************/
/*** END OF FILE ***/
/****************************************************************************/

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top