Help, I/O problem on M8515 port E

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

I have some code that fails... is it a hardware pin fault? brand new CPU... PE0 works as a uart, PE1 I can set low, PE2 won't go low...(setB)

9a30 sbi ddre, 0 ;PE0,1,2 as output
9a31 sbi ddre, 1 ;PE0 = uart.....
9a32 sbi ddre, 2

;set ports as inputs
e090 ldi temp,0x00
bb97 out ddrb, temp

bb91 out ddrd, temp ;
bb94 out ddrc, temp ;
bb9a out ddra, temp ;
;turn on pull-ups
ef9f ldi temp,0xff

bb98 out portb, temp

bb92 out portd, temp ;
bb95 out portc, temp ;
bb9b out porta, temp ;

setA:
9a39 sbi porte,1
9a3a sbi porte,2
9508 ret

setB:
9a39 sbi porte,1
983a cbi porte,2 ;won't set low!
9508 ret

setC:

9839 cbi porte,1 ;will set low !
9a3a sbi porte,2

All the other ports work ok...... is the code ok?Is it likely to be a hardware pin fault or is there a bug in AVR studio that's not assembling the code correctly?
It's doing my head in :(
TIA

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

An easy test is to just connect to your device, and manually set the port to outputs, and then set each bit to 1, the PINx should then be updated with the correct values. The same, set the pins to inputs, and try enabling the pullups to see if you get corrent readings.

You could also to exclude errors in avr studio, messaure with voltmeter or something on the pins as you test each bit

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

Can you please paste the CODE not the listing? Also use the CODE button instaed of quote to make things a little more clear. ie

cbi porte,1 ;will set low ! 
sbi porte,2 

Also which chip are we talking about?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Yeah, what chip. You title says M8515 (Mega8515?), but it DOES NOT have a PE0 as a UART pin --- Maybe a Mega128??

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

Sorry about the CODE didn't know about that.... anyway, it's an AT Mega 8515 and the problem is solved- busted I/O pin. Proved when I managed to recover my other one with HV //programming.
The PE0 is a software uart as the other 4 ports are all being used as inputs and It's easier that way instead or remapping one of the ports that is Txd. As it is I have to bit swap, rotate etc.etc. because I have mapped the hardware to easiest tracking.
I put the listing in just in case the AVR assembler didn't assemble correctly. As it is, there are no port E definitions in the M8515.inc file, so I had to add those myself.
I have to say I struggle with AVR stuff but I am (was) quite proficient with 51 code...But AVR features are way more useful than any 51/2 series, except maybe the Dallas 450 and the a9C51ED2 both with hardware boot< I guess the same is available in AVRs if I looked hard enough, but ISP is plenty good enough.
Projects so far..
Tiny15 I/R 38Khz modulator
Tiny15 fishing buzzer
Tiny2313/Mega8 8 led RGB controller
This project, 24 byte binary to Ascii rs232 bus status monitor.
All hard going ,but enjoyable. :)