![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) | |
| Quote:
It depends upon the receiving program in the PC, they can written to accept binary data, convert to ASCII then display. The usual way is to do the binary to ASCII conversion in the PIC program and transmit ASCII characters, in that way you can use any PC terminal program. Which one do you use? EDIT: just seen Nigels post,, are you planning to use ALL 10 bits or just 8?? At this time the program 'right justifies' the value.
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ Last edited by ericgibbs; 6th October 2007 at 02:52 PM. | ||
| |
| | (permalink) |
| Convert them to ASCII first, then send them. It's dead simple to do - just add 0x30 to the value - check my LCD tutorial routines, subroutine 'CharD' which does just that for LCD. | |
| |
| | (permalink) |
| alright Nigel! let me have a look | |
| |
| | (permalink) |
| hi, As per our PM's Simple example of OS Basic with asm conversion routines for your studies. Code: AllDigital Define SIMULATION_WAITMS_VALUE = 1 'ignore sim delays Define LCD_LINES = 4 Define LCD_CHARS = 16 Define LCD_BITS = 4 Define LCD_DREG = PORTD Define LCD_DBIT = 0 Define LCD_RSREG = PORTE Define LCD_RSBIT = 0 Define LCD_EREG = PORTE Define LCD_EBIT = 2 Define LCD_RWREG = PORTE Define LCD_RWBIT = 1 Define LCD_READ_BUSY_FLAG = 1 Dim ascbfr0 As Byte Dim ascbfr1 As Byte Dim ascbfr2 As Byte Dim ascbfr3 As Byte Dim ascbfr4 As Byte Dim ascbfr5 As Byte Dim ascbfr6 As Byte Dim ascbfr7 As Byte Dim b2avh As Byte Dim b2avm As Byte Dim b2avl As Byte Dim hexval As Byte Dim temp1 As Byte Dim cntr1 As Byte Dim cntr2 As Byte Dim test0 As Byte Dim test1 As Byte Lcdinit test0 = 0 b2avl = test0 hexval = test0 b2avm = 0 b2avl = test0 main: test0 = test0 + 1 b2avl = test0 b2avm = 0 Gosub bin2asc5 Lcdcmdout LcdLine1Home Lcdout ascbfr0, ascbfr1, ascbfr2, Lcdout ascbfr3, ascbfr4, ascbfr5, ascbfr6, ascbfr7 Goto main Gosub byte2asc3 Lcdcmdout LcdLine1Home Gosub showme Gosub hex2asc ascbfr5 = 0x20 Lcdcmdout LcdLine2Home Gosub showme test0 = test0 + 1 b2avl = test0 hexval = test0 Goto main End showme: Lcdout ascbfr5, ascbfr6, ascbfr7 Return 'convert 24 bit bin to 8 asci in ascbfr0 to 7 'or 'b2avh,b2avm,b2avl 'leading spaces in bfr bin2asc5: ascbfr0 = 0 ascbfr1 = 0 ascbfr2 = 0 ascbfr3 = 0 ascbfr4 = 0 ascbfr5 = 0 ascbfr6 = 0 ascbfr7 = 0 ASM: bcf status,rp0 ASM: bcf status,irp ASM: movlw 16 '24 ' bits ASM: movwf cntr1 bitlp: 'shift msb into carry ASM: rlf b2avl,f ASM: rlf b2avm,f 'ASM: rlf b2avh,f ASM: movlw ascbfr7 '0=msd 1st ASM: movwf fsr 'fsr=pointer to digits ASM: movlw 5 '0x8 'digits to do ASM: movwf cntr2 adjlp: ASM: rlf indf,f 'shift digit 1 bit left ASM: movlw 0x0a ASM: subwf indf,W 'check and adjust for overflow ASM: btfsc status,c ASM: movwf indf ASM: decf fsr,f 'incf=msd 1st next digit ASM: decfsz cntr2,f Goto adjlp ASM: decfsz cntr1,f 'next bit Goto bitlp ASM: movlw 0x30 'make asci ASM: iorwf ascbfr0,f ASM: iorwf ascbfr1,f ASM: iorwf ascbfr2,f ASM: iorwf ascbfr3,f ASM: iorwf ascbfr4,f ASM: iorwf ascbfr5,f ASM: iorwf ascbfr6,f ASM: iorwf ascbfr7,f ASM: movf ascbfr0,w 'blank leading zeros ASM: andlw 0x0f ASM: btfss status,z Return Return ASM: bcf ascbfr0,4 'make dig spc ASM: movf ascbfr1,w ASM: andlw 0x0f ASM: btfss status,z Return ASM: bcf ascbfr1,4 ASM: movf ascbfr2,w ASM: andlw 0x0f ASM: btfss status,z Return ASM: bcf ascbfr2,4 ASM: movf ascbfr3,w ASM: andlw 0x0f ASM: btfss status,z Return ASM: bcf ascbfr3,4 ASM: movf ascbfr4,w ASM: andlw 0x0f ASM: btfss status,z Return ASM: bcf ascbfr4,4 ASM: movf ascbfr5,w ASM: andlw 0x0f ASM: btfss status,z Return ASM: nop Return hex2asc: ASM: movf hexval,w Gosub hex1 ASM: movwf ascbfr7 ASM: swapf hexval,w Gosub hex1 ASM: movwf ascbfr6 Return hex1: ASM: andlw 0x0f ASM: addlw 0x30 ASM: movwf temp1 ASM: movlw 0x3a ASM: subwf temp1,w ASM: btfss status,c Goto hex2 ASM: movf temp1,W ASM: addlw 0x7 Return hex2: ASM: movf temp1,W Return 'leading zero's displayed byte2asc3: ASM: movlw 0x0 ASM: movwf ascbfr5 ASM: movwf ascbfr6 ASM: movwf ascbfr7 ASM: bcf status,rp0 ASM: bcf status,rp1 ASM: bcf status,irp ASM: movlw 0x8 ASM: movwf cntr1 binlp1: ASM: rlf b2avl,f ASM: movlw ascbfr7 ASM: movwf fsr ASM: movlw 0x3 ASM: movwf cntr2 binlp2: ASM: rlf indf,f ASM: movlw 0x0a ASM: subwf indf,w ASM: btfsc status,c ASM: movwf indf ASM: decf fsr,f ASM: decfsz cntr2,f Goto binlp2 ASM: decfsz cntr1,f Goto binlp1 ASM: movlw 0x30 ASM: iorwf ascbfr7,f ASM: iorwf ascbfr6,f ASM: iorwf ascbfr5,f Return
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | |
| |
| | (permalink) |
| Hi there Eric.. i have tried the codes for data transmission to the PC via the serial cable and it works... thanks for your help and the PIC simulator IDE really helps.. may i know what can the tools (from PIC simulatior IDE) software UART simulation interface and the PC's serial port terminal do? When i simulate the sample coding you provided me in the previous post.. there are no results on both the tools Are the tools (software UART simulation interface and the PC's serial port terminal ) related to the hardware UART simulation? | |
| |
| | (permalink) | ||
| hi, Quote:
The PC's 'serial port terminal' is a utility program for using the PC's RS232, its not interlinked with the OS sim pins. Does this help?
__________________ Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ | |||
| |
| | (permalink) |
| yea i think this answers the questions.. thanks eric! | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Capturing serial data using PIC24 | nick2412 | Micro Controllers | 3 | 12th March 2007 10:32 PM |
| Need help badly on Inchworm and MPLAB | thushy | Micro Controllers | 14 | 11th March 2007 07:05 PM |
| Need some help with a code provided by ATMEL | ikalogic | Micro Controllers | 1 | 23rd January 2007 03:46 PM |
| Serial Data Logging Software | Monkeyman87 | Micro Controllers | 8 | 12th October 2004 04:32 PM |
| An error in pic16f84a, why? | Zener_Diode | Micro Controllers | 6 | 11th April 2004 03:55 AM |