Searching \ for '16c74 serial routine' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=serial
Search entire site for: '16c74 serial routine'.

Truncated match.
PICList Thread
'16c74 serial routine'
1997\02\19@060528 by Clewer,Brian

flavicon
face
Hi all,
    I have been working on a serial routine using the USART on the 16C74.
My question is why doesn't it work on MPSIM?

I have checked it out several times using the data sheet for 16CXX series.
At first I can see PIR1 <4> is clear when I load the tx data, but when it
becomes set I don't get an interrupt!  Also I never see the tx pin on portc
move.  Do I have to initiate anything else for my program to work?  See
below for program and the response from MPSIM.

;*****************************************
;    serial routine for 16C74 (18/02/97)
;*****************************************

#INCLUDE <16CXX.INC>

TEMP EQU  0X10H     ;TEMP STORAGE



ORG  0X00H
GOTO MAIN


ORG  0X04H
GOTO INTERUPT



MAIN:
CLRF TEMP           ;CLEAR THE STORAGE

MOVLW     B'00000000'         ;SET PORTC AS ALL OUTPUTS
TRIS PORTC               ;    ''
CLRF PORTC               ;CLEAR THE PORT



bsf  STATUS,rp0          ;switch to bank one
BSF  INTCON,GIE          ;ENABLE INTERUPTS

    movlw     .129      ; set up baud rate  (9600 @ 20Mhz)
    movwf     spbrg          ;    ''
bsf  txsta,brgh          ; high baud
bcf  txsta,sync          ;enable port
bcf  status,rp0
bsf  rcsta,spen          ;  ''

bsf  status,rp0          ;bank1
bsf  pie1,txie      ;enable int
bcf  txsta,tx9      ;disable 9 bit
bsf  txsta,txen          ;enable transmission
bcf  status,rp0          ;bank0

MOVFW     TEMP           ;GET TEMP VALUE INTO W
MOVWF     TXREG               ;SEND TO THE TRANSMIT REG



ENDLESS_LOOP:
    NOP
    GOTO ENDLESS_LOOP




INTERUPT:
INCF TEMP,F
MOVFW     TEMP           ;data to be transmitted
movwf     txreg               ;transmit
RETFIE                   ;RETURN




Here is the response I get from MPSIM:



SERIAL           RADIX=X   MPSIM 5.00 D    16c74   TIME=671502.00u
223945?=Help
----------------------------------------------------------------------------
----
PORTC: 00000000  TXREG: 00000000  TRISC: 00000000  TXSTA: 00100100
PIR1: 00010000  PIE1: 00010000  RCSTA: 10000000  SPBRG: 10000001  PORTA:
0001000
PORTB: 11111111  PORTD: 11111111  PORTE: 00000000  W: 00000000  TEMP:
00000000
INTCON: 10000000

----------------------------------------------------------------------------
----
Interrupt at address 16
0017 2816       GOTO    ENDLESS_LOOP
% LO C:\PICDE\HNC\SERIAL
Hex Code loaded
Listing File Loaded
Symbol table loaded
277488 bytes memory free
% RS
Processor Reset
% GO
Interrupt at address 18
0019 2818       GOTO    ENDLESS_LOOP
% AD INTCON,B,8
% C
Interrupt at address 18
0019 2818       GOTO    ENDLESS_LOOP
%



Many thanks for any input (good or bad),
Brian.

1997\02\19@100907 by myke predko

flavicon
face
Brian,

I noticed the same problem on MPLAB's Simulator when I was doing C73A Serial
communication.  And, along with this, the Simulator will not receive
incoming Stimulus file data.

I guess the Simulator core that is used, won't simulate the SCI module.

To debug my code, I ended up writing a small program (similar to yours
below) and debugged it by observing how it worked.  Fortunately, this wasn't
a big job and the hardware works exactly as advertised in the Datasheets.

Good luck,

myke
{Quote hidden}

"I don't do anything that anybody else in good physical condition and
unlimited funds couldn't do" - Bruce Wayne

1997\02\19@115729 by Bob Segrest

picon face
<x-rich>Hi Brian,


>MOVLW     B'00000000'         ;SET PORTC AS ALL OUTPUTS

>TRIS PORTC               ;    ''

>CLRF PORTC               ;CLEAR THE PORT


The PIC16C74 has two banks of registers.  As it happens the TRIS
registers are located in the upper bank.  I don't think the TRIS PORTC
command in your example will work....


I was under the impression something more like this is required...

<paraindent><param>left</param>

MOVLW B'00000000'    ; load W with desired directions

BSF   STATUS,RP0     ; shift to the upper register bank

MOVWF TRISC          ; set the C port TRIS

BCF   STATUS,RP0     ; shift back to the lower registers

CLRF  PORTC          ; clear the C port

</paraindent>

This is the way the app notes for the 16C74 are written at any rate...
If anyone knows this is not required, I would be interested to hear about
it...


Bob Segrest
</x-rich>

1997\02\19@165620 by Andy Kunz

flavicon
face
Bob's code is correct.

Andy


At 11:55 AM 2/19/97 -0500, you wrote:
>Hi Brian,
>
>>MOVLW     B'00000000'         ;SET PORTC AS ALL OUTPUTS
>>TRIS PORTC               ;    ''
>>CLRF PORTC               ;CLEAR THE PORT
>
>The PIC16C74 has two banks of registers.  As it happens the TRIS registers
are located in the upper bank.  I don't think the TRIS PORTC command in your
example will work....
>
>I was under the impression something more like this is required...
>
>MOVLW B'00000000'    ; load W with desired directions
>BSF   STATUS,RP0     ; shift to the upper register bank
>MOVWF TRISC          ; set the C port TRIS
>BCF   STATUS,RP0     ; shift back to the lower registers
>CLRF  PORTC          ; clear the C port
>
>This is the way the app notes for the 16C74 are written at any rate... If
anyone knows this is not required, I would be interested to hear about it...
>
>Bob Segrest
>
==================================================================
Andy Kunz - Montana Design - 409 S 6th St - Phillipsburg, NJ 08865
         Hardware & Software for Industry & R/C Hobbies
       "Go fast, turn right, and keep the wet side down!"
==================================================================

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...