Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Serial communication with PIC12F675

Status
Not open for further replies.
mnavarrete1@sbcglobal.net said:
I am doing something similar with a rfPIC12F675, bit-banging and a GPS module. Its not working yet, but does anyone have any recommendations?

If you've got access to a double beam scope, mod the program so it output a short pulse as it reads each bit, then compare the pulses and the incoming data using the two scope beams. This provides a nice visual indication of how accurate your timing is - each pulse should be in the middle of each bit, although it will work as long as each pulse in in the correct bit.

As before, are you sure the internal oscillator is calibrated correctly?.
 
Nigel's idea is a good one, I've used it to test serial transmission.
 
I don't understand what Nigel is saying. If, whenever I receive a bit I output a pulse, it will always be within the received pulse no matter what speed it is running at. Can someone explain how this helps more than just looking at the received waveform.:confused:

Mike.
 
Pommie said:
I don't understand what Nigel is saying. If, whenever I receive a bit I output a pulse, it will always be within the received pulse no matter what speed it is running at. Can someone explain how this helps more than just looking at the received waveform.:confused:

To receive RS232 you wait for a start bit, then delay 1/2 a bit time, check you're still in the start pulse (send first test pulse out here), then delay 1 full bit time and read the first bit (send second test pulse here), repeat seven more times, with seven more test pulses sent. RS232 is asyncronous, so the receive timing is completely seperate from the incoming signal.

With a double beam scope you can compare the incoming RS232 with the test pulses you've generated - the test pulses should be nicely in the centre of the RS232 bits.
 
Mike said:
I've got an interrupt driven 9600 baud half duplex demo you're welcome to look at if it will help.

Code:
;******************************************************************
;*                                                                *
;*  Filename: 12F675 Serial Demo 3.asm                            *
;*    Author: Mike McLaren, K8LH   (k8lh@arrl.net)                *
;*      Date: 16-Jan-06  (last revision 17-Jan-06)                *
;*                                                                *
;*   Half Duplex Bit-Banged 9600 Baud Serial I/O Demo             *
;*    (2-Pin Version with 8-Byte Circular RX Buffer)              *
;*                                                                *
;*  ·Uses 12F675 INTOSC running at 4-MHz                          *
;*  ·Bit rate error 0.16% plus or minus 1.0% for INTOSC           *
;*  ·Bit-banged 9600 baud serial I/O                              *
;*    ·Half Duplex (should not TX and RX simultaneously)          *
;*    ·TMR0 interrupts at 104-usec intervals (every 104           *
;*     instruction cycles) and IOC (interrupt on change)          *
;*     for RX start bit leading edge detection on RXPIN           *
;*    ·Circular 8-byte RX character buffer                        *
;*    ·Inverted TX and RX signals (MAX232A or similar             *
;*     inverting RS-232 interface required)                       *
;*  ·Relatively small - the ISR and the support routines          *
;*   Init232, Put232, Get232, and PutString use 124 words         *
;*   of code space at locations 0004 through 007F and 20          *
;*   of 64 RAM locations for variables and RX buffer...           *
;*  ·Worst case 51% ISR instruction cycle 'overhead'              *
;*   (54-usecs) when a complete RX character is added to          *
;*   the circular buffer once every 1.04-msecs...                 *
;*                                                                *
;*     MPLab: 7.30    (tabs=8)                                    *
;*     MPAsm: 5.01                                                *
;*                                                                *
;******************************************************************
Hi Mike,
Where in your code would I do to mod your half-duplex program to run at 4800 baud? Thanks
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top