element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Embedded and Microcontrollers
  • Technologies
  • More
Embedded and Microcontrollers
Embedded Forum ecg code with adas1000 on mplabx
  • Blog
  • Forum
  • Documents
  • Quiz
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Embedded and Microcontrollers to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 466 subscribers
  • Views 361 views
  • Users 0 members are here
  • mplabxc16
  • electrocardiogram_(ecg)_solution
  • microcontroller
  • pic
Related

ecg code with adas1000 on mplabx

Former Member
Former Member over 10 years ago

Hello,

i am working on a project to measure and display ecg data on a pc GUI .

I am using ADAS 1000 and pic 24fj64gb002. I have been struggling with the code as it refuse to build.

Its been generating errors when building with Mplabx.

I will like advice on what mistake I am making.

Please find below the code I am working on.

Thanks

Tolu

[

 

 

 

 

 

 

 

/*

 

 

 

* File: ecgmain.c

 

 

 

* Author: TolU

 

 

 

*

 

 

 

* Created on 07 December 2014, 01:31

 

 

 

*/

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

/*********************INCLUDE FILES LIST **************************/

 

 

 

 

 

 

 

 

 

 

 

 

 

  

 

 

 

 

 

#include "p24FJ64GB002.h

 

#include "xc.h"

 

#include "PPS.h"

 

#include "spi.h"

 

#include "ADAS1000.h"

 

 

 

 

 

 

 

 

//ADAS1000 CHIP SELECT PIN INTIALIZATION

 

 

 

 

 

 

 

#define ADAS_CS_TRIS TRISBbits.TRISB2 = 0 //Chip Select an output on RB2 pin

 

#define ADAS_CS PORTBbits.RB2 //Chip Select on RB2 pin

 

 

 

 

 

 

 

 

/***************ADAS1000 SPI FUNCTION DEFINITIONS ******************/

 

 

 

 

 

 

 

void ADAS_SPI_ENABLE()

 

 

 

 

 

 

{

 

 

 

 

 

SPI1STATbits.SPIEN = 1; //ENABLE SPI1

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_SPI_DISABLE()

 

 

 

 

 

 

{

 

 

 

 

 

SPI1STATbits.SPIEN = 0; //DISABLE SPI1

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_PPS_INIT()

 

 

 

 

 

 

{

 

 

 

 

 

__builtin_write_OSCCONL(OSCCON & 0xBF); //Unlock Registers

 

RPINR20bits.SDI1R = 7; //SDI1 on RP07 PIN16

 

RPOR5bits.RP10R = 7; //SDO1 on RP10 PIN21

 

RPOR5bits.RP11R = 8; //SCK1 on RP11 PIN22

 

__builtin_write_OSCCONL(OSCCON | 0x40); //Lock Registers

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_SPI_INIT()

 

 

 

 

 

 

{

 

 

 

ADAS_PPS_INIT();

 

 

 

 

 

//ADAS1000 SPI1 COMM CONFIGURATION

 

 

 

 

 

 

 

 

ADAS_SPI_DISABLE(); //Disable SPI Port

 

SPI1BUF = 0; //Clear SPI Buffer

 

IFS0bits.SPI1IF = 0; //Clear Interrupt Flag

 

IEC0bits.SPI1IE = 0; //DISABLE INTERRUPT

 

SPI1STATbits.SPIROV = 0;//Clear OverFlow Bit

 

 

 

 

 

 

SPI1CON1 = 0x033F;

 

 

 

 

 

/*SPI1CON1 SETTINGS*//*

 

 

 

Internal SPI CLK enabled, SDOx pin controlled by module, 8-bit comm,

 

 

 

Data_in sampled at end of output time, SDO changes on Active to Idle clock,

 

 

 

SSx pin not used,Idle clock state is low, Master Mode, Sec=1:1, Pri=1:1*/

 

 

 

 

 

 

 

 

SPI1CON2 = 0x0000;

 

 

 

 

 

/*SPI1CON2 SETTINGS*//*

 

 

 

Framed SPI disabled, Frame sync pulse output, Frame sync pulse active low,

 

 

 

Frame sync pulse before first bit clock, enhance buffer diabled*/

 

 

 

 

 

 

 

 

ADAS_SPI_ENABLE(); //ENABLE SPI PORT

 

 

 

 

 

 

}

 

 

 

 

 

/**************ADAS1000 FUNCTION DEFINITIONS *********************/

 

 

 

 

 

 

 

 

void ENABLE_ADAS()

 

 

 

 

 

 

{

 

 

 

 

 

ADAS_CS = 0; //SELECT ADAS1000 CHIP

 

 

 

 

 

 

}

 

 

 

 

 

void DISABLE_ADAS()

 

 

 

 

 

 

{

 

 

 

 

 

ADAS_CS = 1; //DESELECT ADAS1000 CHIP

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_ECGCTL_INIT()

 

 

 

 

 

 

{

 

 

 

 

 

ADAS_SPI_INIT(); //READY ADAS-MCU SPI COMMUNICATION

 

ENABLE_ADAS(); //ENABLE ADAS1000 SPI COMMUNICATION

 

WriteSPI1(ECGCTL1); //WRITE 4-BYTE CMD TO ECGCTL CONTROL REGISTER

 

 

 

 

 

 

WriteSPI1(ECGCTL2);

 

 

 

WriteSPI1(ECGCTL3);

 

 

 

WriteSPI1(ECGCTL4);

 

 

 

 

 

ReadSPI1(); //READ SPI1BUF TO CLEAR FLAGS

 

DISABLE_ADAS(); //DISBALE ADAS1000 SPI COMMUNICATION

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_FRMCTL_INIT()

 

 

 

 

 

 

{

 

 

 

 

 

ADAS_SPI_INIT(); //READY ADAS-MCU SPI COMMUNICATION

 

ENABLE_ADAS(); //ENABLE ADAS1000 SPI COMMUNICATION

 

WriteSPI1(FRMCTL1); //WRITE 4-BYTE CMD TO FRMCTL CONTROL REGISTER

 

 

 

 

 

 

WriteSPI1(FRMCTL2);

 

 

 

WriteSPI1(FRMCTL3);

 

 

 

WriteSPI1(FRMCTL4);

 

 

 

 

 

ReadSPI1(); //READ SPI1BUF TO CLEAR FLAGS

 

DISABLE_ADAS(); //DISBALE ADAS1000 SPI COMMUNICATION

 

 

 

 

 

 

}

 

 

 

 

 

void ADAS_INIT()

 

 

 

 

 

 

{

 

 

 

ADAS_ECGCTL_INIT();

 

 

 

ADAS_FRMCTL_INIT();

 

 

 

}

 

 

 

 

 

void ADAS_READ_DATA()

 

 

 

 

 

 

{

 

 

 

ADAS_SPI_INIT();

 

 

 

 

 

//SEND ADAS1000 READ COMMAND

 

 

 

 

 

 

 

 

ENABLE_ADAS();

 

 

 

WriteSPI1(FRAMES1);

 

 

 

WriteSPI1(FRAMES2);

 

 

 

WriteSPI1(FRAMES3);

 

 

 

WriteSPI1(FRAMES4);

 

 

 

DISABLE_ADAS();

 

 

 

 

 

//READ ADAS1000 HEADER DATA

 

 

 

 

 

 

 

 

ENABLE_ADAS();

 

 

 

HEADER_RX[1] = ReadSPI1(SPI1BUF);

 

 

 

HEADER_RX[2] = ReadSPI1(SPI1BUF);

 

 

 

HEADER_RX[3] = ReadSPI1(SPI1BUF);

 

 

 

HEADER_RX[4] = ReadSPI1(SPI1BUF);

 

 

 

DISABLE_ADAS();

 

 

 

 

 

//READ ADAS1000 Left Arm (LA) DATA

 

 

 

 

 

 

 

 

ENABLE_ADAS();

 

 

 

LA_RX[1] = ReadSPI1(SPI1BUF);

 

 

 

LA_RX[2] = ReadSPI1(SPI1BUF);

 

 

 

LA_RX[3] = ReadSPI1(SPI1BUF);

 

 

 

LA_RX[4] = ReadSPI1(SPI1BUF);

 

 

 

DISABLE_ADAS();

 

 

 

 

 

//READ ADAS1000 Left Leg (LL) DATA

 

 

 

 

 

 

 

 

ENABLE_ADAS();

 

 

 

LL_RX[1] = ReadSPI1(SPI1BUF);

 

 

 

LL_RX[2] = ReadSPI1(SPI1BUF);

 

 

 

LL_RX[3] = ReadSPI1(SPI1BUF);

 

 

 

LL_RX[4] = ReadSPI1(SPI1BUF);

 

 

 

DISABLE_ADAS();

 

 

 

 

 

//READ ADAS1000 Right Arm (RA) DATA

 

 

 

 

 

 

 

 

ENABLE_ADAS();

 

 

 

RA_RX[1] = ReadSPI1(SPI1BUF);

 

 

 

RA_RX[2] = ReadSPI1(SPI1BUF);

 

 

 

RA_RX[3] = ReadSPI1(SPI1BUF);

 

 

 

RA_RX[4] = ReadSPI1(SPI1BUF);

 

 

 

DISABLE_ADAS();

 

 

 

ADAS_SPI_DISABLE();

 

 

 

 

 

]

 

On building I got the following errors.

 

[EC2.c:70:11: error: 'ECGCTL1' undeclared (first use in this function)
EC2.c:70:11: note: each undeclared identifier is reported only once for each function it appears in
EC2.c:71:11: error: 'ECGCTL2' undeclared (first use in this function)
EC2.c:72:11: error: 'ECGCTL3' undeclared (first use in this function)
EC2.c:73:11: error: 'ECGCTL4' undeclared (first use in this function)
EC2.c: In function 'ADAS_FRMCTL_INIT':
EC2.c:81:1: warning: statement with no effect
EC2.c:81:11: error: expected ';' before 'FRMCTL'
EC2.c:82:1: warning: statement with no effect
EC2.c:82:11: error: expected ';' before 'FRMCTL'
EC2.c:83:1: warning: statement with no effect
EC2.c:83:11: error: expected ';' before 'FRMCTL'
EC2.c:84:1: warning: statement with no effect
EC2.c:84:11: error: expected ';' before 'FRMCTL'
EC2.c: In function 'ADAS_READ_DATA':
EC2.c:98:11: error: 'FRAMES1' undeclared (first use in this function)
EC2.c:99:11: error: 'FRAMES2' undeclared (first use in this function)
EC2.c:100:11: error: 'FRAMES3' undeclared (first use in this function)
EC2.c:101:11: error: 'FRAMES4' undeclared (first use in this function)
EC2.c:105:1: error: 'HEADER_RX' undeclared (first use in this function)
EC2.c:112:1: error: 'LA_RX' undeclared (first use in this function)
EC2.c:119:1: error: 'LL_RX' undeclared (first use in this function)
EC2.c:126:1: error: 'RA_RX' undeclared (first use in this function)
EC2.c:131:1: error: expected declaration or statement at end of input
make[2]: *** [build/default/production/EC2.o] Error 255
make[2]: *** Waiting for unfinished jobs....
nbproject/Makefile-default.mk:108: recipe for target 'build/default/production/EC2.o' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
make[2]: Leaving directory 'C:/Users/TOLUWALOPE/Desktop/ECO/EC.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/TOLUWALOPE/Desktop/ECO/EC.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 11s)]

  • Sign in to reply
  • Cancel
  • clem57
    0 clem57 over 10 years ago

    void ADAS_FRMCTL_INIT()     //Need a ; after every statement and this one is missing

    The others are missing INCLUDE xxxx.H files for the headers. I cannot tell without seeing the code you downloaded in total...

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube