| Arduino Forum ::  Members :: dmd
 Show Posts Pages: [1] 2
 1 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 28, 2014, 02:37:04 pm (You do know that ^ means XOR, not exponent, right?)
 2 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 28, 2014, 02:33:44 pm Quoteand 4 ^ 0 is 1 as you would expectWait, what? 4 ^ 0 is 4, not 1.As expected, I get 142857, which means the prescaler is coming out as 4, which is what 4 ^ 0 is.
 3 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 28, 2014, 01:22:54 pm So I guess my question is about the prescaler.The first answerer above said:Code:uint32_t prescaler = 4 ^ (TWSR & 0x03);uint32_t freq = 16000000L / (16 + 2 * TWBR * prescaler);But freq would be 400 only if prescaler = 1.
 4 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 28, 2014, 01:08:55 pm I am setting TWBR correctly according to the link you just posted.F_CPU = 16000000speed = 400TWBR = (F_CPU/(speed*1000) - 16)/2;So TWBR = 12 which is what I have up above.
 5 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 28, 2014, 10:54:45 am I finally got a chance to actually try this.If I say:Code:Wire.begin();                                // set up I2C commsTWSR &= 0xFC;                                // set I2C frequency of 400KTWBR = 12;uint32_t i2c_prescaler = 4 ^ (TWSR & 0x03);uint32_t i2c_freq = 16000000L / (16 + 2 * TWBR * i2c_prescaler);and then later onCode:serial_printf("i2c=%d\n", (int) (i2c_freq / 1000))It prints 142 instead of the expected 400.If I put the Wire.begin() after the two register setting lines instead of before them, I get 27 instead of the expected 400.What am I doing wrong?
 6 Using Arduino / Networking, Protocols, and Devices / Re: change I2C speed WITHOUT modifying library? on: May 19, 2014, 11:35:21 am Thank you!
 7 Using Arduino / Networking, Protocols, and Devices / change I2C speed WITHOUT modifying library? on: May 19, 2014, 10:14:12 am Is there any way to change I2C speed from 100K to 400K in one's own code, i.e. without modifying libraries/Wire/utility/twi.h?  I would like to ensure that if someone else later builds my code having re-downloaded the libraries, they don't unknowingly revert to 100K speed.Alternatively, is there any way to detect in my code what speed I2C is running at - either at runtime, or, ideally, during the build process (I build from edam's Arduino makefile).
 8 Using Arduino / Microcontrollers / Lifetime of EEPROM? on: December 29, 2012, 04:09:00 pm I want to keep some data safe in case the power goes out, so I've been using the EEPROM library to write it out every minute or so.Yes, I know the right answer is to monitor my power and write if it starts to fail.I'm just wondering - am I going to damage the EEPROM/have it fail prematurely if I write to it so often? How many write cycles can it take?
 9 Using Arduino / Displays / Re: Sainsmart LCD2004 newbie question - can't get it working on: December 15, 2012, 04:17:19 pm I GOT IT! It was 0x3F.I ran http://omarfrancisco.com/i2c-bus-scanner/  (which didn't work in Arduino v1, but I ran it under 23 and it discovered the I2C device at 0x3F).
 10 Using Arduino / Displays / Re: Sainsmart LCD2004 newbie question - can't get it working on: December 15, 2012, 04:03:51 pm Ok, still trying this, on the off chance that it's not actually defective.I've looked around but can't find a datasheet online for this, and it's soldered on so I can't look and see. How can I figure out what the I2C address is?
 11 Using Arduino / Displays / Re: Sainsmart LCD2004 newbie question - can't get it working on: December 15, 2012, 03:11:11 pm It looks based on some Amazon reviews like this may have come with a defective I2C board. I'm going to return it. fm, can you recommend a source to buy a LCD display with I2C that will work?
 12 Using Arduino / Displays / Re: Sainsmart LCD2004 newbie question - can't get it working on: December 15, 2012, 02:43:31 pm Changing I2C_ADDR to 0x20 has no effect.
 13 Using Arduino / Displays / Sainsmart LCD2004 newbie question - can't get it working on: December 15, 2012, 02:29:12 pm I have a Sainsmart LCD2004 with 20x4 display.I've removed the LiquidCrystal library that came with my arduino software, and installed instead fmalpartida's new-liquidcrystal library.I have an Arduino Uno R3, and I connected the LCD2004's VCC to Uno 5V, LCD GND to Uno GND, LCD SDA to Uno A4, LCD SCL to Uno A5.I tried running this code:Code:/*** Example Arduino sketch for SainSmart I2C LCD2004 adapter for HD44780 LCD screens** Readily found on eBay or http://www.sainsmart.com/ ** The LCD2004 module appears to be identical to one marketed by YwRobot**** Address pins 0,1 & 2 are all permenantly tied high so the address is fixed at 0x27**** Written for and tested with Arduino 1.0** This example uses F Malpartida's NewLiquidCrystal library. Obtain from:** https://bitbucket.org/fmalpartida/new-liquidcrystal **** Edward Comer** LICENSE: GNU General Public License, version 3 (GPL-3.0)**** NOTE: TEsted on Arduino NANO whose I2C pins are A4==SDA, A5==SCL*/#include #include #include #define I2C_ADDR    0x27  // Define I2C Address where the PCF8574A is#define BACKLIGHT_PIN     3#define En_pin  2#define Rw_pin  1#define Rs_pin  0#define D4_pin  4#define D5_pin  5#define D6_pin  6#define D7_pin  7int n = 1;LiquidCrystal_I2C       lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);void setup(){  lcd.begin (20,4);  // Switch on the backlight  lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);  lcd.setBacklight(LOW);  lcd.home ();                   // go home  lcd.print("SainSmart I2C tester");    lcd.setCursor ( 0, 1 );        // go to the 2nd line  lcd.print("F Malpartida library");  lcd.setCursor ( 0, 2 );        // go to the third line  lcd.print("Test & demonstration");  lcd.setCursor ( 0, 3 );        // go to the fourth line  lcd.print("Iteration No: ");}void loop(){  // Backlight on/off every 3 seconds  lcd.setCursor (14,3);        // go col 14 of line 3  lcd.print(n++,DEC);  lcd.setBacklight(LOW);      // Backlight off  delay(3000);  lcd.setBacklight(HIGH);     // Backlight on  delay(3000);}And nothing happens at all. (The backlight is on once I connect VCC and GND, but the display never changes - it just looks like this:I'm clearly missing something simple... what do I do?Thanks!
 14 Forum 2005-2010 (read only) / Troubleshooting / Re: 0005 won't run on OSX PPC on: September 15, 2006, 08:04:38 am Aha! Thanks very much.
 15 Forum 2005-2010 (read only) / Troubleshooting / Re: 0005 won't run on OSX PPC on: September 14, 2006, 04:08:45 pm Please read my original post, where I showed that I am already running Java 1.5.0_06.I am running OS X 10.4.7.
 Pages: [1] 2