Irolan
Newbie level 5

Hi everyone,
first of all, I'm sorry if this was already answered somewhere, I searched but couldn't find anything like this.
I have the following problem.
I'm using a 8051 derivate, the Atmel AT89C5131 controller and write my programs in Keil µVision 4. Recently, I tried to work with the serial interface, but found that it doesn't seem to work.
So, what I'm trying to do is this: I have have two identical controllers, connected via serial interface (serial to serial, NOT usb) the first one sends signals to the second one, which is then supposed to process them and show them on a display. The first controller works fine and it also sends stuff, I checked that using an oscylloscope.
Here's the parts of the code relevant for the serial interface:
Now, here's the problem. Whatever I do, the serial buffer register SBUF contains no value. So, A+dptr always equals 0+dptr, meaning whatever the interface receives, the data pointer always points at the first address of the table, thus always returning the starting value.
I tried moving the clr RI command, since I thought maybe that clears the SBUF too, no change.
I tried giving the Accu a fix value, that works. So it's obviously the SBUF not receiving a value.
Also, although I'm sending signals to the serial interface, the serial interrupt is never triggered.
The problem seems to be in my code, not in the connection. While debugging, I changed the value of SBUF and forced an interrupt, still "mov A,SBUF" does not do anything.
Does anyone know what's going on?
first of all, I'm sorry if this was already answered somewhere, I searched but couldn't find anything like this.
I have the following problem.
I'm using a 8051 derivate, the Atmel AT89C5131 controller and write my programs in Keil µVision 4. Recently, I tried to work with the serial interface, but found that it doesn't seem to work.
So, what I'm trying to do is this: I have have two identical controllers, connected via serial interface (serial to serial, NOT usb) the first one sends signals to the second one, which is then supposed to process them and show them on a display. The first controller works fine and it also sends stuff, I checked that using an oscylloscope.
Here's the parts of the code relevant for the serial interface:
Code:
;-------------------------------------------------------------------------------------------------------------------------------------------------------
;HEAD
...
org 0023h ;vector address for serial interrupt
ljmp serial_int
...
;-------------------------------------------------------------------------------------------------------------------------------------------------------
;MAIN PROGRAM
...
clr SM0
setb SM1 ;UART mode 1 (8-bit variable)
clr SM2 ;no multi processor mode
setb REN ;enable serial reception
;set baud rate to 4800
mov BRL,#178
mov BDRCON,#00000110b ;set RBCK (internal bdr-generator for reception), fast generator (SPD)
orl PCON,#1000000b ;set SMOD1 without touching the rest of the bits
setb ES ;enable serial interrupt
orl BDRCON,#00010000b ;set BRR to start generator without touching the rest of the bits
...
;-------------------------------------------------------------------------------------------------------------------------------------------------------
;SERIAL INTERRUPT
serial_int:
jnb RI,ri_not_set ;jump if RI flag is not set, otherwise...
clr RI ;...since we are here, the last interrupt was a reception, RI is now set – thus clear RI
mov A,SBUF ;...store received signal in accu
movc A,@A+dptr ;...indirect indexed addressing of table, store in accu
mov P0,A ;...send content of accu to port 0 (in this case, there's a 7-segment-display I'm trying to gate)
sjmp end_serial ;...jump to return
ri_not_set:
clr TI ;since we are here, the last interrupt was a transmission, TI is set – thus clear TI
end_serial:
reti ;we're done here, return to main program
Now, here's the problem. Whatever I do, the serial buffer register SBUF contains no value. So, A+dptr always equals 0+dptr, meaning whatever the interface receives, the data pointer always points at the first address of the table, thus always returning the starting value.
I tried moving the clr RI command, since I thought maybe that clears the SBUF too, no change.
I tried giving the Accu a fix value, that works. So it's obviously the SBUF not receiving a value.
Also, although I'm sending signals to the serial interface, the serial interrupt is never triggered.
The problem seems to be in my code, not in the connection. While debugging, I changed the value of SBUF and forced an interrupt, still "mov A,SBUF" does not do anything.
Does anyone know what's going on?
Last edited: