Reply by "s.h...@btinternet.com" July 29, 20092009-07-29
Bazza,

I am using an atmel attiny device, i wrote the program in c, i have a definition for setting a port

#define bit_set_hi(Port,Bit) Port |= _BV(Bit)

and if i use it i.e bit_set_hi(PORTB,PB2); it works fine, when i analyse the asm code generated by the c compiler i get

sbi 0x18,2 and this works fine.

The example below, sbi portd,1 is not the same as ldi temp 0x01 out portd, temp it's a different bit (Bits are numbered 0 - 7 , look in the instruction set , you need to change your bit command to sbi portd,0 to be the same command as ldi temp 0x001, out portd,temp

So you are setting the wrong bit with the sbi command.

Regards

--- In a..., "bazzapromenade" wrote:
>
> Nope definitely an output, same problem on port d on the pins,on d that I am using as an output.Using internal oscillator and not using the reset pin. As I said, wherever I used for eg sbi portd 1 with nothing connected to any output pins, using a dvm I would get an output of 3.5v..
> Doing nothing other than changing that spot of code to read
> ldi temp, 0x01
> out portd, temp
> this gives me 5v at the pin.
> bazza.
> >
> > Sounds like you are trying to turn on a port set as an input (This would turn on the pull up so depending on the impedance you are connected would in effect be a potential divider).
> >
> > You mention setting a bit in port a but port a is the reset and crystal connections, are you using an internal oscillator , which bit in porta are you trying to use ? is it set by fuses to a reset/osc pin ?
> >
> > Regards
> >
> > --- In a..., "bazzapromenade" wrote:
> > >
> > > I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
> > > Many thanks Bazza.
> > >
>

Reply by bazzapromenade July 28, 20092009-07-28
Nope definitely an output, same problem on port d on the pins,on d that I am using as an output.Using internal oscillator and not using the reset pin. As I said, wherever I used for eg sbi portd 1 with nothing connected to any output pins, using a dvm I would get an output of 3.5v..
Doing nothing other than changing that spot of code to read
ldi temp, 0x01
out portd, temp
this gives me 5v at the pin.
bazza.
>
> Sounds like you are trying to turn on a port set as an input (This would turn on the pull up so depending on the impedance you are connected would in effect be a potential divider).
>
> You mention setting a bit in port a but port a is the reset and crystal connections, are you using an internal oscillator , which bit in porta are you trying to use ? is it set by fuses to a reset/osc pin ?
>
> Regards
>
> --- In a..., "bazzapromenade" wrote:
> >
> > I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
> > Many thanks Bazza.
>

Reply by bazzapromenade July 28, 20092009-07-28
>The port is an output. 0xff
> Bazza
>
> The "Data Port Direction" (DDRx) is?
>
> Edson
> ----- Original Message -----
> From: bazzapromenade
> To: a...
> Sent: Monday, July 27, 2009 12:03 AM
> Subject: [AVR club] ATtiny 2313 floating output?
> I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
> Many thanks Bazza.
>
>
>
>
>

Reply by "s.h...@btinternet.com" July 28, 20092009-07-28
Sounds like you are trying to turn on a port set as an input (This would turn on the pull up so depending on the impedance you are connected would in effect be a potential divider).

You mention setting a bit in port a but port a is the reset and crystal connections, are you using an internal oscillator , which bit in porta are you trying to use ? is it set by fuses to a reset/osc pin ?

Regards

--- In a..., "bazzapromenade" wrote:
>
> I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
> Many thanks Bazza.
>

Reply by Elbest Engenharia July 28, 20092009-07-28
Bazza

The "Data Port Direction" (DDRx) is?

Edson
----- Original Message -----
From: bazzapromenade
To: a...
Sent: Monday, July 27, 2009 12:03 AM
Subject: [AVR club] ATtiny 2313 floating output?
I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
Many thanks Bazza.



Reply by bazzapromenade July 27, 20092009-07-27
I have come across something that I do not quite understand. I am running a simple code that uses 4 pins as inputs and the rest are outputs. I write in assembler code. The program runs fine in simulation but i found a glitch when used in real life. In my code there was a couple of dozen places where there would be most of portB on as output high and maybe a single pin high on port A or D. To cut corners with the lone pins I used an SBI PORTAx on the single pin. On the larger output port d I used the usual ldi to a temp then an out to the port. Now here's the weird bit.. Any time I used sbi, the pin turned on but only to about 3.5 volts. Using the normal ldi they would turn on to 5v. I went through my whole program and tested the outputs and it was the same outcome every single time an sbi was used. Changed the code to the usual LDI TEMP, 0Xxx OUT PORTA, TEMP and all was well. I can not find any data on what causes this and do not understand how the chip would know any difference. Once the code is converted to hex the chip would not know the difference. Has anyone come across this and can shed some light on it.
Many thanks Bazza.