CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

pic 16F88 usart issue

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PICJoey



Joined: 19 Feb 2009
Posts: 1

View user's profile Send private message

pic 16F88 usart issue
PostPosted: Thu Feb 19, 2009 7:08 pm     Reply with quote

Hi,
I am workin on PIC16f88 USART and not able to get it to work. I actually downloaded a code from a forum and programmed the microcontroller with it, but it doesnt work.
The code has to transmit the word "test" to the hyperterminal at 9600Mbps, I cannot see any thing in the hyperterminal. I am using a external 4MHz oscillator.
Every thing in the code seems to b fine, all the registers set properly. I dont know whats goin on wrong Sad . Please let me know if some thing is wrong with the code.
Code:

include p16f88.inc

 

        org      0x000

count equ 0x20


main   ; bcf   STATUS,RP0
       ; bcf      STATUS,RP1
        clrf     PORTA
        clrf     PORTB

        ; RB2 - Incoming Data RX
        ; RB5 - Outgoing Data TX
        movlw    B'11011111'
        bsf      STATUS,RP0
        movwf    TRISB

        ; 4MHz for 9600 baud rate
        ; See http://www.picbasic.co.uk/forum/showthread.php?t=214
        movlw    0x19
        movwf    SPBRG

        ; 8-bit asych mode, high speed uart enabled
        movlw    0x24   ; BRGH=1  20 BRGH=0
        movwf    TXSTA

        ; Serial port enable, 8-bit asych continous receive mode
        movlw    0x90
        bcf      STATUS,RP0
        movwf    RCSTA

loop1   movlw   0x45   ;'t'
        call    putc
        call    delay
        movlw   0x65   ;'e'
        call    putc
        call delay
        movlw   0x47   ;'s'
        call    putc
        goto delay
        movlw   0x45   ;'t'
        call    putc
        call delay
        movlw   0x0D   ; CR
        call    putc
        call  delay
        movlw   0x0A   ; LF
        call    putc
         

        ; remove next line and program will echo input from PC
        goto    loop1

loop2   nop
        getc   btfss   PIR1,RCIF
        goto   getc
        movf    RCREG,W
        call    putc
        goto    loop2

putc    btfss   PIR1, TXIF
        goto   putc
        movwf   TXREG
       movlw   0xf
       movwf   count
     
        return

delay
    nop
    nop
    nop
    nop
   decfsz count
   goto  delay
   return
   end
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Thu Feb 19, 2009 7:24 pm     Reply with quote

...

Last edited by dyeatman on Thu Feb 19, 2009 7:35 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 19, 2009 7:26 pm     Reply with quote

Do you have the CCS compiler ? This is not a Microchip MPASM forum.
If you do, here's a test program:
Code:
#include <16F88.H>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_B5, rcv=PIN_B2, ERRORS)

//============================
void main()
{
int8 c;

while(1)
  {
   c = getc();   // Get char from PC
   putc(c);  // Send it back to the PC
  }

}

If you're using MPASM (with MPLAB), then you should ask your questions
in the Microchip UART forum:
http://forum.microchip.com/tt.aspx?forumid=12
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group