Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 20th June 2007, 02:53 PM   (permalink)
Default

Are you sure the polarity of the data was correct?, remember the MAX232 inverts it - and are you sure the baud rate was set correctly?. Both of these will give weird characters.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 21st June 2007, 06:59 AM   (permalink)
Default

Yes, the baud rate was set correctly as follows in software.

TXBYTE MOVWF BYTE ;save table value to BYTE
MOVLW 0x08
MOVWF BITCNT ;do eight times
BCF TXPIN ;SEND START BIT
CALL Bit_Delay ;delay 104 instruction cycles
;assuming 4MHz clock, that's 1us per instruction cycle
;so delaying 104us
TXLOOP RRF BYTE,F ;move BYTE bit0 into carry
BTFSS STATUS, C ;a Low ?
BCF TXPIN ;yes, send it
BTFSC STATUS, C ;a High?
BSF TXPIN ;yes, send it
CALL Bit_Delay
DECFSZ BITCNT
GOTO TXLOOP ;loop for 7 more times
BSF TXPIN ;SEND STOP BIT
CALL Bit_Delay
RETURN
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Old 21st June 2007, 07:04 AM   (permalink)
Default

sorry about the above post, the 104us delay is generated as follows, I have simulated the program using mplab and the timing is correct.
Bit_Delay
MOVLW 0x21
MOVWF DELAYCNT

DELAYLOOP
DECFSZ DELAYCNT ;one cycle if DELAYCNT
GOTO DELAYLOOP ;two cycles
RETURN
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Old 21st June 2007, 07:23 AM   (permalink)
Default

My code snippets are not coming out clearly, what do I do?
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Old 21st June 2007, 08:05 AM   (permalink)
Default

Quote:
Originally Posted by emufambirwi
My code snippets are not coming out clearly, what do I do?
Surround them with the 'Code' tags, click on the 'Advanced' button where it's an option.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 21st June 2007, 08:21 AM   (permalink)
Question

I did not receive a comment on my delay, is it ok
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Old 21st June 2007, 08:35 AM   (permalink)
Default

Quote:
Originally Posted by emufambirwi
I did not receive a comment on my delay, is it ok
I didn't check it, just use the one from my tutorial which is known to work (uses a 4MHz clock).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 21st June 2007, 12:21 PM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin
Are you sure the polarity of the data was correct?, remember the MAX232 inverts it
How do I invert the data again in software?
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Old 21st June 2007, 01:50 PM   (permalink)
Default

Quote:
Originally Posted by emufambirwi
How do I invert the data again in software?
Switch the BCF's and BSF's in the transmit routine - don't forget the start and stop bits as well.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now   Reply With Quote
Old 22nd June 2007, 09:47 AM   (permalink)
Default

ok thanks, feedback later
__________________
People perish because of lack of knowledge
emufambirwi is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes




All times are GMT. The time now is 12:32 PM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.