Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About eckertc

  • Rank
  1. Thanks Trossin i will definatley be taking a look at that link. and as long as we are on the topic of serial communications, is the internal clock of the PIC16F628A accurate enough to handle stable communications or is it nessesary to use an external oscillator??
  2. In addition to the above questions. i have another question reguarding the Rs232 driver provided with the samples. could someone please explain in a bit of detail about what each of these are and what the values represent? // PIC16F87x defaults for hardware USART support //#define TX_PORT 0x07 //#define TX_TRIS 0x87 //#define TX_BIT 6 //#define RX_PORT 0x07 //#define RX_TRIS 0x87 //#define RX_BIT 7 //#define e_SPBRG 0x99 //#define e_RCREG 0x1a //#define e_TXREG 0x019 //#define e_TXSTA 0x98 //#define e_RCSTA 0x18 //#define e_TXIF_PIR 0x0c //#define e_RCIF_PIR 0x0c //#define e_TXIF_BIT 4 //#define e_RCIF_BIT 5 //#define MODE (USART_reset_wdt | USART_HW)
  3. Hey all, First let me just say sorry for the size of this post. its going to be a bit of a long winded one but I'm not sure how to get my full question accross without explaining it fully. With that said.... Here goes nothing.... I am moving on to working with Serial communications on the PIC16F628A now and i'm working with kind of a goofy protocol. /////////////////////////////////////////////////////// // Desired setup result for PIC16F628A: // //////////////////////////////////////////////////// What i would like to see is the following: // Baud Rate: 9600 NRZ // Serial Bit Format: // 1 Start Bit // 8 Data Bits // 1 Mode Bit(used as address bit) // 1 Stop Bit // ------------- // 11 Bits Total // // Details: This device will need to be set up like // a slave device, answering only when // addressed. a typical transmission from // the master device will look like the // the following: // (address(mode) byte, data bytes, and a // checksum byte.) // // If a byte is recieved with the "Mode" // bit set to 1, proccess it as an address // bit and react or dont react depending // on if the sender was addressing you. // If the sender WAS addressing you, and // following bytes are recieved with the // "Mode" bit set to 0, proccess it as a // data bit and respond with appropriate // responce. ////////////////////////////////////////////////////////// My take on how to accomplish this is in as follows. Please let me know if you think this is being handled properly or if you have any advice on this type of setup. ////////////////////////////////////////////////////////// // Pin8-(RB2): set RB2 as TX(out) line with a baud // rate of 9600 at clock speed of 4Mhz. // Enable 9bit transfer mode. // Set USART for Synchronous Mode. // Set Baud rate to High-Speed. // Set Transmit Shift Register Status // bit to 1 = TSR empty // Set TX9D bit = 0 // ////////////////// - In other words - ///////////////// // TXSTA(0x98h) = 11110110 = 0xF6h ///////////////////////////////////////////////////////// // Pin7-(RB1): set RB1 as RX(in) line with a baud // rate of 9600 at clock speed of 4Mhz. // Enable the serial port // Set for 9bit reception. // Single recieve enable.(doesnt matter) // Enable continuous receive // Enable Address Detect bit // Disable Framing Error bit // Disable Overrun Error bit // Set TX9D bit = 1 ////////////////// - In other words - ///////////////// // RCSTA(0x18h) = 11111001 = 0xF9h ///////////////////////////////////////////////////////// I have read the Datasheet for the PIC16F628A all the way through multiple times (an exahsting 169 pages) and the above setup seems the closest to what I need to accomplish but being a complete beginner with PIC programming in general it is simply my best guess at this point. Any advice you could offer would be very helpfull.
  4. Thanks Twomers I think that is the littel push i needed to get going in the right direction. for anyone else reading this post, another helpfull resource I found thanks to twomers input was the file in C:\Program Files\SourceBoost\Samples\C\BoostC\ez called USARTRecieve.c. on another note, is there anyway to simulate serial communication with a plugin the way you can simulate an LED or a Button? It would be very helpful to simulate serial functions in the software to save time debugging on the hardware.
  5. Hey all, First i would like to say THANK YOU sourceboost for creating this excellent software package. I have been looking for weeks for a way to get into PIC programming using C and your software has been the least painfull of all. now to the meat of the post. I have been going through the beginners section doing the simple tutorials (or not so simple but getting there tutorials) and have even made a modified version of the Blinking LED source that uses a 2 state button to turn on and off the LED. #include <system.h> #include "Project1.h" #pragma CLOCK_FREQ 4000000 // config clock to 4mhz. // Set configuration fuse. #pragma DATA _CONFIG, _XT_OSC & _WDT_OFF & _CP_OFF & _PWRTE_OFF void main() { trisb = 1; //configure port B pins as input trisa = 0; //configure port A pins as output while( 1 ) { if(trisb.0==0) //check If button is pushed { porta.0=1; //if button is pushed turn on LED } if(trisb.0==1) { porta.0=0; } } } with a few of these small projects under my belt now and looking forward to doing the rest, i was wondering if someone could point me in the right direction to find more info i doing something with Serial Tx and RX. the final project i have in mind is using the PIC16F628A to accomplish the following. set up the PIC16F628A for full duplex. set up the PIC16F628A for using the 9th data bit on both TX and RX. (sometime bit 9 will = 0 sometimes bit 9 will = 1) (ex. 1 start bit, 8 data bits, 1 address bit, 1 stop bit) set up the PIC16F628A at 9600 baud rate. monitor two seperate serial(TTL Level) lines coming from two seperate peripherals for communication. If one of my peripherals sends data, read it. if it is one of many expected communications we are waiting for from this peripheral, send it the appropriate responce. If not, reset. any suggestions on this would be wonderful help. one thing im still not clear on is if this is even possible with only one PIC16F628A do to only having one USART Tx and one RX. any ideas??
  • Create New...