Pages: 1 [2]   Go Down
Author Topic: Mistery: I2C not working, blink working  (Read 1806 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello again. I bought oscilloscope today and tried to measure what's going on.

Same programm on arduino uno and arduino mega. Right connection to both.

This is oscillogramm from uno(it's good):
On mega no impulses appear.

I also made an experiment. I wrote this code to mega and use oscilloscpe with it:
Code:
void setup()  {
  // nothing happens in setup
}

void loop()  {
 while(true){
    analogWrite(21, 0);        
    delay(1000);
    analogWrite(21, 100);        
    delay(1000);
    analogWrite(21, 255);        
    delay(1000);    
  }
}
But i saw only one impulse at 5V with 1sec duration and then 2sec 0V.

My theory is that DAC is broken, but I still don't know why I2C isn't working.

Anyway powering from battery doesn't give any results.
« Last Edit: November 30, 2012, 12:43:19 pm by Spin7ion » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    analogWrite(21, 0);   
Does pin 21 have a little squiggly next to it to indicate that it is a PWM pin? If not analogWrite isn't going to do anything.   
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    analogWrite(21, 0);   
Does pin 21 have a little squiggly next to it to indicate that it is a PWM pin? If not analogWrite isn't going to do anything.   

Oh, my fault, you are right. But it not explains why does not I2C working.

As I understand I2C is digital protocol, but why we can use ony 2 pins for it?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As I understand I2C is digital protocol, but why we can use ony 2 pins for it?

Because the AVR chip uses special internal hardware to support the I2C function and it only wires that function to those two specific pins. Just like the hardware serial function on a standard Uno is only available on pins 0 and 1, same thing going on there. analogWrite (pwm outputs) only works on specific pins because it uses internal chip hardware timers that only wire up to specific pins. All I/O pins can be used as simple digital input or output pins, but most of the special functions of the chip are only supported by specific pins. The AVR datasheet is the best source of information on this topic.

Lefty
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
As I understand I2C is digital protocol, but why we can use ony 2 pins for it?

Because the AVR chip uses special internal hardware to support the I2C function and it only wires that function to those two specific pins. Just like the hardware serial function on a standard Uno is only available on pins 0 and 1, same thing going on there. analogWrite (pwm outputs) only works on specific pins because it uses internal chip hardware timers that only wire up to specific pins. All I/O pins can be used as simple digital input or output pins, but most of the special functions of the chip are only supported by specific pins. The AVR datasheet is the best source of information on this topic.

Lefty

Can this special internal hardware be damaged?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Can this special internal hardware be damaged?
Any hardware can.
Logged

Pages: 1 [2]   Go Up
Jump to: