PortB Low Activated?

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

Hi, I am just getting started with AVR and I have an ATMega8535 and STK500. I wrote some code to take in data over the RSR232 port using polling and then just dump it out to PortB where the LEDs are connected. Thing is, I'm getting the inverse of everything. For example, I send to it an A and I get 10111110 which is 190 (and Z is 10100101 which is 165). If I NOT each LED, I get the correct number 65 (and 90). Because I don't have, or maybe don't know how to use, the on-chip debugger, my question is: Why is it being NOT'ed? Is the RS232 doing it, or the PortB? Thanks! Code to follow:[P]

.include "m8535def.inc"
.def Temp = R16        
.org 0x0000            
; Set PortB to output
	ser Temp
	out DDRB,Temp 

; Set baud rate
	ldi Temp, 0x00;
	out UBRRH, Temp; 
	ldi Temp, 12
	out UBRRL, Temp ;init baudrate

; Enable Receiver Only, by polling
	ldi Temp, (1<<RXEN)
	out UCSRB,Temp
	; 8n1
	ldi r16, (1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1)
	out UCSRC,Temp

USART_Receive:
	sbis UCSRA, RXC		
	rjmp USART_Receive;

	in Temp, UDR       
	out PORTB, Temp 
	rjmp USART_Receive   
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The LEDs on the STK500 are active low. This is very common when driving loads such as LEDs. The schematics for the STK500 are available; check the STK500 entry in the Tools section of this Web site.

[Note that the switches are also active low, IIRC.]

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Thanks!