MCU User Forum
  port P0 error

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone! next newest topic | next oldest topic
Author Topic:   port P0 error
msa
New Member
posted August 06, 2010 02:09 PM     Click Here to See the Profile for msa   Click Here to Email msa     Edit/Delete Message
Hi all
I am new user for Silicon Lab
I have C8051f350-TB

1) i need Assembly language documentation for C8051f350.

2)I need to toggle LED 1 using assembly language
when i execute this code in (The Silicon Laboratories IDE )show me error when using P0

//////////////////
BACK: MOV A,#00H
MOV P0,A
ACALL DELAY
MOV A,#0FFH
MOV P0,A
ACALL DELAY
SJMP BACK
;---------- this is delay subroutine ------------
ORG 300H
DELAY: MOV R5,#0FFH
AGAIN: DJNZ R5,AGAIN
RET
END


[This message has been edited by msa (edited August 06, 2010).]

IP: Logged

Scotty
Member
posted August 06, 2010 02:47 PM     Click Here to See the Profile for Scotty     Edit/Delete Message
Hi msa,

1) i need Assembly language documentation for C8051f350.
Read datasheet, rev.1.1, p89-91 and this link:
https://www.silabs.com/Marcom%20Documents/Training%20Videos/8051_Instruction_Set_Online_FINAL.pdf

2)I need to toggle LED 1 using assembly language
when i execute this code in (The Silicon Laboratories IDE )show me error when using P0

Which error? What means "using P0"? Using it in your code, or IDE port IO window?
Always post detailed information. Saying it doesn't work is only the half...
Your code has no comments. Currently, this is a small and easy piece of code, but for future please comment what your code is doing -> this is often helpful, because sometimes it shows you what you think the code should do, and helps to find out what the code is really doing.

I have C8051f350-TB...
Just to give you a example for the use of comments:
- I have to assume that your code posted above is complete and starting at 0x0000.
- I cannot locate the comment regarding the deactivation of the default enabled watchdog, and therefore I have to assume that your code will never work without deactivating the watchdog.
- ...

You see, comments might be helpful, at least for you, but surely for others to realize what your code does and what it should do.

Regards,

Scotty

IP: Logged

erikm
Member
posted August 06, 2010 08:59 PM     Click Here to See the Profile for erikm   Click Here to Email erikm     Edit/Delete Message
when i execute this code

code????

last I heard code had indentions and comments

Erik

IP: Logged

picperson
Member
posted August 07, 2010 04:19 AM     Click Here to See the Profile for picperson     Edit/Delete Message
Well done for having a go with assembler.
Documentation on assembler for a specific MCU your not going to get.
A good book for the 8051 MCU on which the F350 is based is 'The 8051 Microcontroller' by Kenneth J. Ayala, get the second or third edition. This is aways available on Ebay and possibly free download if you do a web search.
Have a look though the application notes in Silicon Labs Support..Documents and Knowlege base on how to use individual peripherals ect.

Take the advice of both scotty and erikm, cut and paste your code from the IDE to your post so everything your doing can be seen, errors often are found in the intialisation of the MCU which you have not given.
No matter how trivial the program always document/ use comments.
Indent by using the tab key and keep labels at the start of a block of code on a line by itself to make clear where the block of code starts. Neatness of code always makes it easier to follow.
I have cut and pasted Silicon Labs 'Blinky' program that is supplied with the developments kit as an example.

$NOMOD51
;-----------------------------------------------------------------------------
; Copyright (C) 2007 SILICON LABORATORIES, INC.
; All rights reserved.
;
; FILE NAME : F35x_BLINKY.ASM
; DATE : 06 FEB 04
; TARGET MCU : C8051F35x
; DESCRIPTION : This program illustrates how to disable the watchdog timer,
; configure the Crossbar, configure a port and write to a port
; I/O pin.
;
; NOTES:
;
;-----------------------------------------------------------------------------

$include (c8051f350.inc) ; Include register definition file.

;-----------------------------------------------------------------------------
; EQUATES
;-----------------------------------------------------------------------------

GREEN_LED equ P0.7 ; Green LED: '1' is ON

;-----------------------------------------------------------------------------
; RESET and INTERRUPT VECTORS
;-----------------------------------------------------------------------------

; Reset Vector
cseg AT 0
ljmp Main ; Locate a jump to the start of
; code at the reset vector.

;-----------------------------------------------------------------------------
; CODE SEGMENT
;-----------------------------------------------------------------------------


Blink segment CODE

rseg Blink ; Switch to this code segment.
using 0 ; Specify register bank for the
; following program code.

Main:
; Disable the WDT.
anl PCA0MD, #NOT(040h) ; clear Watchdog Enable bit

; Enable the Port I/O Crossbar
mov XBR1, #40h ; enable Crossbar
orl P0MDOUT, #80h ; make LED pin output push-pull
orl P0MDIN, #80h ; make LED pin input mode digital

; Initialize LED to OFF
clr GREEN_LED

; Simple delay loop.
Loop2: mov R7, #03h
Loop1: mov R6, #00h
Loop0: mov R5, #00h
djnz R5, $
djnz R6, Loop0
djnz R7, Loop1
cpl GREEN_LED ; Toggle LED.
jmp Loop2

;-----------------------------------------------------------------------------
; End of file.

END


Unfortunatley this cut and paste has taken all the indentation/alignment out and Iam not smart enough to know if it is possible to cut and paste whilst keeping it in!!
Iam sure someone can show me.:-)

Mike

[This message has been edited by picperson (edited August 07, 2010).]

IP: Logged

msa
New Member
posted August 08, 2010 03:19 PM     Click Here to See the Profile for msa   Click Here to Email msa     Edit/Delete Message
Hi all

I solved my error

see my code
//////////////


P0MDOUT DATA 0A4H ; PORT 0 OUTPUT
PCA0MD DATA 0D9H ; PCA MODE
XBR1 DATA 0E2H ; PORT I/O CROSSBAR CONTROL 1

ANL PCA0MD, #NOT(040h) ; clear Watchdog Enable bit


; Enable the Port I/O Crossbar
MOV XBR1, #40h ; enable Crossbar
ORL P0MDOUT, #0C0h ; make LED pin output push-pull


MAIN:ACALL DELAY
cpl 80H.7 ; Toggle LED.
jmp MAIN


;---------- this is delay subroutine ------------
ORG 300H
DELAY: mov R3, #05h
AGAIN1: mov R2, #00h
AGAIN0: mov R1, #00h
djnz R1, $
djnz R2, AGAIN0
djnz R3, AGAIN1
RET
END


[This message has been edited by msa (edited August 10, 2010).]

IP: Logged

vanmierlo
Member
posted August 09, 2010 01:08 PM     Click Here to See the Profile for vanmierlo   Click Here to Email vanmierlo     Edit/Delete Message
Indent by using the tab

NO, don't do that! The forum (and html) will not know what to do with them. Always use spaces to indent when posting to this (any?) forum.

Unfortunatley this cut and paste has taken all the indentation/alignment out and I am not smart enough to know if it is possible to cut and paste whilst keeping it in!!
I am sure someone can show me.:-)

For the umpteenth time: put the code between <pre> and </pre> to preserve the indentation in this (any?)forum.

Btw. "I" and "am" are two words.

Maarten

IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | MCU User Forum

Have you seen our MCU Knowledge Base?


Ultimate Bulletin Board 5.47b