cancel
Showing results for 
Search instead for 
Did you mean: 

I/O programming in asm

a00178074
Associate II
Posted on October 25, 2005 at 02:18

I/O programming in asm

6 REPLIES 6
a00178074
Associate II
Posted on October 19, 2005 at 21:29

Hello!

I'm working with a ST72F324 MCU. I want to set a port like an output (PA4). When programming in C, I do the next:

PADDR=0xFF;

PAOR=0xFF;

PADR=0xFF;

and the led in this port is set, but when programming in asm, i do the next:

BSET PADDR,#4

BSET PAOR,#4

BSET PADR,#4

I hope with this code, the led on PA4 would be set but it doesn't.

Please, what is happening, I think i'm configuring correctly the I/O.

Thanks.

fggnrc
Associate II
Posted on October 20, 2005 at 06:17

SSAM,

the ASM equivalent code of the C snippet is:

LD A,#$FF

LD PADDR,A

LD PAOR,A

LD PADR,A

What you wrote is different, because it touches only the bit #4, instead of all pins.

Are you sure that the led is attached to the right pin?

EtaPhi

a00178074
Associate II
Posted on October 20, 2005 at 16:57

Thanks a lot, EtaPhi

I have done the same you wrote, my main program do the next:

.main

call port_init

loop

jra loop

.port_init

LD A,#$FF

LD PADDR,A

LD PAOR,A

LD PADR,A

ret

but running the program don't set the led in any PA port. When I use the similator it does'n set the PA ports anyway. The program is simple like this but i don't understand what is happenning. The ports are ok, because i probed them with the program in C.

I tried doing with a bit instruction bset,#4, after configuring like an output pin, but it didn't work.

I have to conect the MCU to a ST7538 and i need to generate REG_DATA AND RXTX signals from the MCU to the ST7538.The program i have is in assembler.

Could be something wrong in my workspace configuration?

fggnrc
Associate II
Posted on October 21, 2005 at 05:13

It is very strange...

Since the C program code works, then the bug must lie in the asm source which is so simple...

By the way, which hardware definition file do you include?

I mean, the file which contains the definitions of HW ports i.e. PADR, PADDR and PAOR.

Replace PADR with $00, PADDR with $01 and PAOR with $02 (these are the common addresses for Port A registers, but check your datasheet) and see what happens.

You can also watch at the output of the C compiler.

After that, I have no more hint...

Bye

EtaPhi

laurent239955_stm1
Associate II
Posted on October 24, 2005 at 07:11

You can generate a listing file (*.lst) by checking the option in the compiler. Then you can verify that the generated assembler code corresponds with yours.

Best regards

Laurent

a00178074
Associate II
Posted on October 25, 2005 at 02:18

Hello!!

The problem was solved. The only thing i did was download the new version of the ST7VD and taking the program to the root c:\.

It is something i don't understand. Then with the ST7VD 3.1 the ports didn't work?

Could someone explain to me what was the problem with the ST7VD and the ports?

:(

Thank you again.

SSAM