Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/30/03 06:34
Read: times


 
#49679 - RE: Why not use QBASIC?
Responding to: ???'s previous message
1) the 8051 runs out of stack
2) I´m not able to use constants defines by equ


Problem #1 may be due a couple of things, both having to do with using interrupt-driven serial I/O. First an interrupt essentially does an implicit CALL to the ISR address, pushing the return address on the stack. Your serial ISR, by doing an ACALL, is pushing yet another return address on the stack, yet your ISR only returns once. So every serial interrupt entry/exit, you end up pushing 4 bytes and popping 2 bytes. Secondly, you have the serial receiver enabled too, but are not handling it in the serial ISR, so if RI becomes set and you never clear it, you'll end up with that interrupt source always pending. That, combined with the net +2 byte stack growth gets you in trouble in a hurry! I'm going to recommend that you avoid using interrupts for the time being. After you get polled serial I/O working properly, then you could consider adding the interrupt capability.

Problem #2 may be due to using a mix of hexadecimal notations. Your assembler may not handle the '$' that some assemblers do for other processor families. I'd recommend sticking with the 0xxH convention for hexadecimal numbers, since most 8051 assemblers consistently use that convention.

I took the liberty of quickly reorganizing your code a little bit to eliminate the ISR for now, and make the hexadecimal notations consistent, but I did not test these modifications. Try working with it some and see if you can get further along.

INICIO_TABLA EQU 040H
FIN_TABLA    EQU 0FFH

        .ORG 0H                 ;locate routine at 00H
        AJMP START              ;jump to START
        .ORG 03H                ;external interrupt 0
        RETI
        .ORG 0BH                ;timer 0 interrupt
        RETI
        .ORG 13H                ;external interrupt 1
        RETI
        .ORG 1BH                ;timer 1 interrupt
        RETI
        .ORG 23H                ;serial port interrupt
        RETI
        .ORG 25H                ;locate beginning of rest of program

SEND:   MOV SBUF, A             ;Transmit Byte
WAIT:   JNB TI, WAIT            ;Wait for transmission to be completed.
        CLR TI                  ;Clear Transmit Flag
        RET

START:  ;Main program (on power up, program jumps to this point)
        ;Set up control registers
        MOV PCON, #080H         ;to double baud rate
        MOV TH1,  #0FDH         ;Set up for 9600 baud rate
        MOV SCON, #01010000B    ;Mode = 8 bit UART
        MOV TMOD, #00100001B    ;Sets Timer1 to 8 bit auto reload
        MOV TCON, #01000000B    ;Turns Timer1 on
        MOV R0,#INICIO_TABLA

LOOP:   MOV A,@R0               ;Move Value in R0 to A (to be sent)
        CALL SEND               ;Send Value to PC
        INC R0                  ;Increase the 8 bit value of R0 by 1
        MOV A,R0
        CJNE A,#FIN_TABLA,LOOP  ;Go to LOOP(jump back to point labeled LOOP)

        JMP $
        END



List of 35 messages in thread
TopicAuthorDate
URGENT: serial comuinication 8051            01/01/70 00:00      
   RE: URGENT: serial comuinication 8051            01/01/70 00:00      
      RE: URGENT: serial comuinication 8051            01/01/70 00:00      
         RE: URGENT: serial comuinication 8051            01/01/70 00:00      
         RE: URGENT: serial comuinication 8051            01/01/70 00:00      
            RE: URGENT: serial comuinication 8051            01/01/70 00:00      
            RE: URGENT: serial comuinication 8051            01/01/70 00:00      
         RE: URGENT: serial comuinication 8051            01/01/70 00:00      
   RE: URGENT: serial comuinication 8051            01/01/70 00:00      
      RE: URGENT: serial comuinication 8051            01/01/70 00:00      
   Why not use QBASIC?            01/01/70 00:00      
      RE: Why not use QBASIC?            01/01/70 00:00      
         RE: Why not use QBASIC?            01/01/70 00:00      
         RE: Why not use QBASIC?            01/01/70 00:00      
            RE: Why not use QBASIC?            01/01/70 00:00      
               RE: TurboPower AsyncPro            01/01/70 00:00      
            RE: Why not use QBASIC?            01/01/70 00:00      
               RE: Why not use QBASIC?            01/01/70 00:00      
                  RE: Why not use QBASIC?            01/01/70 00:00      
                     RE: Why not use QBASIC?            01/01/70 00:00      
                  Want the 50 mili second loop code            01/01/70 00:00      
         RE: Why not use QBASIC?            01/01/70 00:00      
      RE: Why not use QBASIC?            01/01/70 00:00      
         RE: Why not use QBASIC?            01/01/70 00:00      
            RE: Why not use QBASIC?            01/01/70 00:00      
               RE: Why not use QBASIC?            01/01/70 00:00      
                  RE: Why not use QBASIC?            01/01/70 00:00      
         RE: Why not use QBASIC?            01/01/70 00:00      
         Basic is for kids?            01/01/70 00:00      
            RE: Basic is for kids?            01/01/70 00:00      
               RE: Basic is for kids?            01/01/70 00:00      
                  RE: Basic is for kids?            01/01/70 00:00      
   RE: URGENT: serial comuinication 8051            01/01/70 00:00      
      URGENT: serial comuinication 8051! help            01/01/70 00:00      
         RE: URGENT: serial comuinication 8051! help            01/01/70 00:00      

Back to Subject List