AVR Studio 4.17..... ATMega8 missing! (?)

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Where is ATmega8 ?

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The JTAGICEmkII only lists (even for ISP) the chips that have JTAG or debugWire.

If you want to use a JTAGICEmkII to ISP program a mega8 then either use avrdude or edit the XML files for mega8 to "lie" that it has JTAG

Cliff

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I presumed that...
My AVR ISP MK II died last night. (MISO or MOSI grounded I believe), so I desperately looking for USB programmer before tomorrow. (or programmer wich work with usb-232 conversion FT232RL).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Like I say, avrdude has no qualms about using the jtagicemkii to do ISP to a mega8

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all, I am making a program in which I am interfacing LM75A (temperature IC) with Atmega8 using I2C and then getting the value of temperature serially to my laptop. I have written the code but I think there is some problem in it and that's why I am not getting exact output. please help.

Here is the code:

#ifndef F_CPU
#define F_CPU 8000000UL 
#endif

#include <avr/io.h>
#include<util/delay.h>
#include <stdio.h>

//Serial tansmit
void serial_avr(char *str)
{
    UCSRB=(1<<TXEN);
    UCSRC=(1<<UCSZ1)|(1<<UCSZ0)|(1<<URSEL);
    UBRRL=51;
    
    for (unsigned int i=0;str[i]!=0;i++)
    {
        UDR=str[i];
        //UDR = 0;
        while(!(UCSRA&(1<<UDRE)));
    }

    _delay_ms(500);
}

void i2c_init(void)
{
     TWSR=0x00;            
     TWBR=0x47;            
    TWCR=0x04;        
}

void i2c_start(void)
{
        TWCR = (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
        while ((TWCR & (1 << TWINT)) == 0);
}

void i2c_write(unsigned char data)
{
        TWDR = data ;
        TWCR = (1<< TWINT)|(1<<TWEN);
        while ((TWCR & (1 <<TWINT)) == 0);
}

unsigned char i2c_read(unsigned char isLast)
{
        if (isLast == 0)
        TWCR = (1<< TWINT)|(1<<TWEN)|(1<<TWEA);
        else
        TWCR = (1<< TWINT)|(1<<TWEN);
        while ((TWCR & (1 <<TWINT)) == 0);
        return TWDR  ; 
    
}

void i2c_stop()
{
            TWCR = (1<< TWINT)|(1<<TWEN)|(1<<TWSTO);
}

void main(void)
{
        
         char temp; 
                        
        i2c_init();
        i2c_start();
        i2c_write(0b10010001); //slave address for LM75A
        i2c_write(0x00); //temperature register address
        temp = i2c_read(1);
        i2c_stop();
            
        while(1)
        {
            serial_avr(temp);
            _delay_ms(2000);
               
        }

}

 

>

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Why have you posted to this thread? You question has no relevance to the thread subject?

 

BTW your code makes no sense whatsoever. The i2c_read function returns a "char", you assign it to "temp" but then you pass this as a parameter to serial_avr() as "char *" not just "char" then you treat it as if it were a string?

 

I'm astonished the C compiler even compiled this without error - there MUST have been a warning at the very least when you used "serial_avr(temp)"?

 

Anyway if you want to convert a 0..255 value to a string of ASCII digits to show on a terminal you need to use a numeric to string conversion routine such as itoa() or sprintf() or similar.

 

(also is "char" the right type anyway - at the very least I guess you mean "unsigned char"?)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can I post new questions here.?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can I post new questions here.?