My USART problems..


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Sep 2008
    Location
    Stockholm
    Posts
    80

    Default My USART problems..

    I'm building a thing that really could use some serial out and input, so I decided to try to finally use the USART's in some pics..

    First I tried to get it to work in my nearly-finished testrig for the rest of the stuff, but when this didnt work I built a "serial testring" to be able to sort out the problems.

    But no. get nothing in my term program.

    This is my testcode..

    Code:
    ' Serial testrig 1.0 Glenn a t repulsiv.se
    
    @ device PIC16F877A,HS_OSC,LVP_OFF,WDT_OFF,PROTECT_OFF
    
    ' Lets define..
    
    DEFINE OSC 20	' Lets work at 20MHz
    
    ' And the LCD..
    	DEFINE LCD_DREG	PORTD				' Set LCD Data port
    	DEFINE LCD_DBIT	0						' Set starting Data bit (0 or 4) if 4-bit bus
    	DEFINE LCD_RSREG	PORTD			' Set LCD Register Select port
    	DEFINE LCD_RSBIT	4					' Set LCD Register Select bit
    	DEFINE LCD_EREG	PORTD				' Set LCD Enable port
    	DEFINE LCD_EBIT	5						' Set LCD Enable bit
    	DEFINE LCD_BITS	4						' Set LCD bus size (4 or 8 bits)
    	DEFINE LCD_LINES	2					' Set number of lines on LCD
    	DEFINE LCD_COMMANDUS	2000	' Set command delay time in us
    	DEFINE LCD_DATAUS	50				' Set data delay time in us
    
    ' And the serial port using USART.
    	DEFINE HSER_BAUD 9600   ' HSER baud rate
    	DEFINE HSER_SPBRG 129   ' HSER SPBRG init
    	DEFINE HSER_RCSTA 90h   ' HSER receive status init
    	'DEFINE HSER_TXSTA 24h   ' HSER transmit status init high speed
    	DEFINE HSER_TXSTA 20h   ' HSER transmitter init
    
    
    pause 1000	' Gracetime for the LCD
    
    Main:
    	LCDOUT $FE, 1, "Hello world"
    	pause 500
    	LCDOUT $FE, $C0, "Again and again"
    	pause  500
    	LCDOUT $FE, 1
    	pause 500
    	gosub serial
    	pause 500
    	goto main:
    	
    serial:
    	HSEROUT ["Glenn",10]
    	Return
    ..I tried different things, but this should work ? or ?

    I attached a schematics of my simple testrig.
    Attached Images Attached Images  
    Last edited by Glenn; - 29th July 2009 at 17:48.

Similar Threads

  1. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  2. USART TXREG Problems
    By BigH in forum Serial
    Replies: 2
    Last Post: - 11th January 2006, 00:30
  3. USART problems
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 6th March 2005, 21:45
  4. Replies: 5
    Last Post: - 1st December 2004, 12:49
  5. Synchronous USART problems... HELP!!!
    By moni in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th November 2003, 19:00

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts