极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14530|回复: 5

AD9850模块程序问题

[复制链接]
发表于 2015-5-13 15:47:13 | 显示全部楼层 |阅读模式
从网上找了一段用AD9850模块做信号发生器的代码,出现了
As of Arduino 1.0, the 'BYTE' keyword is no longer supported.
Please use Serial.write() instead.                    
求教各位大神这个问题,怎么解决。
下面是原代码
/*********************************************************************
**  Device: AD9850/9851                                             **
**  File:   EF_AD9850.cpp v1.2                  **
**                    **
**  Created by ElecFreaks Robi.W /28 Oct 2011                       **
**                                                                  **
**  Description:                                                    **
**  This file is a sample code for your reference.About AD9850/9851 **
**  module use on Arduino with serial mode. And then show the       **
**  square wave and sine wave by LXARDOSCOPE which is an free       **
**  Arduino based oscilloscope Linux, using the Xforms library.     **
**  Note:This library just Serial mode for AD9850                   **
**                                                                  **
**  This demo code is free software; you can redistribute it and/or **
**  modify it under the terms of the GNU Lesser General Public      **
**  License as published by the Free Software Foundation; either    **
**  version 2.1 of the License, or (at your option)           **
**  any later version.                **
**                                                                  **
**  Copyright (C) 2011 ElecFreaks Corp.                           **
**                                                                  **
**  http://www.elecfreaks.com                                       **
*********************************************************************/

#include <EF_AD9850.h>

//Define for LXARDOSCOPE
int sensorValue = 0;        // value read from the pot
byte lb;
byte hb;

//BitData - D8, CLK - D9, FQUP - D10, REST - D11
EF_AD9850 AD9850(9, 10, 11, 8);

void setup()
{
  AD9850.init();
  AD9850.reset();
  AD9850.wr_serial(0x00, 200); //200Hz
  // initialize serial communications at 115200 bps:
  Serial.begin(115200);
}

void loop(){
  // read A0:
  sensorValue = analogRead(A0);
// shift sample by 3 bits, and select higher byte
  hb=highByte(sensorValue<<3);
// set 3 most significant bits and send out
  Serial.print(hb|224,BYTE);
// select lower byte and clear 3 most significant bits
  lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
  Serial.print(lb|96,BYTE);
// read A1
  sensorValue = analogRead(A1);
// shift sample by 3 bits, and select higher byte
  hb=highByte(sensorValue<<3);
// set bits 5 and 6 and send out
  Serial.print(hb|96,BYTE);
// select lower byte and clear 3 most significant bits
  lb=(lowByte(sensorValue))&31;
// set bits 5 and 6 and send out
  Serial.print(lb|96,BYTE);
}

回复

使用道具 举报

发表于 2015-5-13 19:26:05 | 显示全部楼层
版本问题,BYTE该关键字不支持
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-5-14 14:29:33 | 显示全部楼层
suoma 发表于 2015-5-13 19:26
版本问题,BYTE该关键字不支持

那怎么改呢?
回复 支持 反对

使用道具 举报

发表于 2015-5-15 10:23:35 | 显示全部楼层
剑门细雨 发表于 2015-5-14 14:29
那怎么改呢?

换成1.0之前的试一下
回复 支持 反对

使用道具 举报

发表于 2015-5-15 10:24:36 | 显示全部楼层
应该有相关键字替代,我没用过byte,char行不行?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-5-15 17:09:44 | 显示全部楼层
suoma 发表于 2015-5-15 10:24
应该有相关键字替代,我没用过byte,char行不行?

我又从其他网站新找了一段新代码解决了,多谢了。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-20 22:19 , Processed in 0.045809 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表