Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help with PowerPC's (MPC823) or assembly coding

Status
Not open for further replies.

Chris P

New Member
Hello,

Im a student and as part of a project at uni i need to sexamine switchs attached to port D of a PowerPC (MPC823) I have set up all the addresses to do this but cant move the actual switch positions onto a register. Here is my code so far...

"
// This code sets up port D as inputs so that the switch states can be examined


// Define section type - text for source code

.text

// Define global labels.

.global go

// Define address offsets for registers used

pddir = 0x0970 // (p16-494)
pddat = 0x0976 // (p16-494)
pdpar = 0x0972 // (p16-495)

.org 0x1000
go:
li r10, 0x000 // for testing to check registers change
li r11, 0x000 // when the same program is run consecutively
li r12, 0x000 //
li r13, 0x000 // for testing to check registers change
li r14, 0x000 // when the same program is run consecutively
li r15, 0x000
li r16, 0x000 // for testing to check registers change
li r17, 0x000 // when the same program is run consecutively
li r18, 0x000
li r19, 0x000 // for testing to check registers change
li r20, 0x000 // when the same program is run consecutively


// Registers are stated as an offset from the IMMR
// & oxFFFF0000 therefore this value must first be loaded

mfspr r10,immr // get immr contents from the board
lis r11,0xffff // load r11 with lower bits of 0xFFFF0000
ori r11,r11,0x0000 // load r11 with upper bits of 0xFFFF0000
and r10,r10,r11 // AND with peripheral base address
// r10 now points to base address

// Initialise registers
// Port D: pg16-493

li r11,0x0000 // load r11 with 0x0000 for port setup
sth r11,pdpar(r10) // pbpar=0000=PortB operation (p16-495)
sth r17,pddir(r10) // pbddr=0000=Inputs (p16-494)

// Store the switch positions into register 20

sth pddat(r14),r12 // for testing to check registers change
"

Sorry about the spacing! :)
The problem is with the last line "sth pddat(r14),r12" I want to move the binary value set by the switch positions onto register r12, however this command generates an error when the program is compiled.
"Argument out of range got 2422, expected value between 0 and 31
sth pddat(r14),r12 "
I guess you cant use the sth command to do this then?
Does anyone know the correct command, or could anyone point me to a good source of info. Cheers people

Chris P
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top