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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • 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
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • 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
Arduino
  • Products
  • More
Arduino
Arduino Forum BV4213 I2C Motor Controller Issue
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 2 replies
  • Subscribers 416 subscribers
  • Views 361 views
  • Users 0 members are here
Related

BV4213 I2C Motor Controller Issue

e14 Contributor
e14 Contributor over 12 years ago

Hello,


I am getting used to the I2C protocol, so do not laugh at me if I ask something dumb. I have bought an I2C-based device, the BV4213 motor controller. I have connected it to arduino using 10KOhm pullup resistors at the VDD line. But when I send the command "Test EEPROM" it returns 255 and when I send the command "Print Firmware Version" (I request from it 2 bytes) it returns -1 and -1.  The commands are (copied word-by-word from the datasheet):


Command 0x55 (Test EEPROM)

Format: < S-addr><0x55><start><R- 0x42>s 93 r g-1 p

Addr><Value..><NACK><Stop>

BV4221 Example

0x42>s 55 r g-3 p

The above command will return 1,2,3 if the

device is connected and working correctly.

This command simply returns an incrementing

value until NACK is sent by the master prior to

stop. This can be useful for testing the

interface. It can be used for testing the presence or

other wise of a device at a particular address.

It is also useful during the development stage

to ensure that the I2C is working for that

device.


2. Command 0xA0 (Print Firmware Version)

0x42>s a0 r g-2 p

This will return the two firmware bytes.

This simply returns two bytes that represents

the firmware version.



My code is:

Test EEPROM: void testEeprom()

Print Firmware version: void printFV()

 

Quote

#include <Wire.h>

 


void setup() {
  Wire.begin();
  Serial.begin(9600);
  printFV();
  //printID();
  Serial.println();
 
  byte aByte = testEeprom();
  Serial.println(aByte);
 
 
  //enableY3Y4();
 
  Serial.println("End");
 
}

 

 

 

void loop() {
}

 

byte testEeprom() {
Wire.beginTransmission(0x42);
Wire.write(0x55);
Wire.endTransmission();
Wire.requestFrom(0x42, 1);
while(Wire.available()) {
}

 

byte res = Wire.read();
return res;
}

 


void printID() {
Wire.beginTransmission(0x42);
Wire.write(0xA1);
Wire.endTransmission();
Wire.requestFrom(0x42, 2);
while(Wire.available()) {
}

Serial.print(Wire.read());
Serial.print(Wire.read()); 
}

 

void enableY3Y4() {
    Wire.beginTransmission(0x42);
  Wire.write(2);
  Wire.write(1);
  Wire.endTransmission();
}

 

void printFV() {
  Wire.beginTransmission(0x42);
  Wire.write((byte) 0xA0);
  Wire.endTransmission();
  Wire.requestFrom(0x42, 2);
  while(Wire.available())
  {
  }

 

Serial.println(Wire.read());
Serial.println(Wire.read());

 

}

 

 


Besides I have also tried putting 330hm pullups but the result remained alike. What's going on?


Thanks in advance


PS I intend to upload a schematic if you request me to do so! Moreover, the BV4213 Datasheet is attached.

I use an Arduino UNO


Attachments:
imageBV4213 DataSheet.pdf
image
  • Sign in to reply
  • Cancel
Parents
  • e14 Contributor
    e14 Contributor over 12 years ago

    Hi Marios,

     

    I'm curious about the use of this snippet in several of your functions:

     

      while(Wire.available()) {

      }

     

    It looks to me as if you

    1. request data
    2. spin doing nothing while data is available. Then once it has become unavailable
    3. try to read it, getting -1 for "no data available"

     

    I'd revisit that before modifying the hardware (which I haven't checked).

     

    Regards,

      Colin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • e14 Contributor
    e14 Contributor over 12 years ago

    Hi Marios,

     

    I'm curious about the use of this snippet in several of your functions:

     

      while(Wire.available()) {

      }

     

    It looks to me as if you

    1. request data
    2. spin doing nothing while data is available. Then once it has become unavailable
    3. try to read it, getting -1 for "no data available"

     

    I'd revisit that before modifying the hardware (which I haven't checked).

     

    Regards,

      Colin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
  • e14 Contributor
    e14 Contributor over 12 years ago in reply to e14 Contributor

    Huh! Seems that there was a logic mistake. That was true and I haven't noticed it perhaps because I've written this code very quickly! So, I inverted the logic and replaced it with:

     

    while(!Wire.available()) {
    }

     

    The machine is now returning nothing :-/

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • 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 © 2026 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.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube