Go Down

Topic: Mistery: I2C not working, blink working (Read 2436 times) previous topic - next topic

Spin7ion

#15
Nov 30, 2012, 06:41 pm Last Edit: Nov 30, 2012, 06:43 pm by Spin7ion Reason: 1
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: [Select]

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.

PaulS

Code: [Select]
    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.   

Spin7ion


Code: [Select]
    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?

retrolefty

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

Spin7ion


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?

PaulS

Quote
Can this special internal hardware be damaged?

Any hardware can.

Go Up