Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About threespeers

  • Rank
  1. Thanx to all who helped! I seemed to have had my dirty glasses on and there was no light! I was taling to the other port on the board. That was the problem! This chip is actually quite powerfull and I would recomend it!
  2. A framing error is usually an indication of incorrect baud rate or UART configuration mismatch between both ends. It will also occur if you have a polarity mismatch (line driver at one end only) A framing error is cleared by reading the RCREG. <{POST_SNAPBACK}>
  3. Hi, I seem to get a framing error! How do you fix that?
  4. Hi, I have to right through a rs232 chip to the port. I read that in the serial driver and I am aware that I will have to change it for the second UART but I cannot even get the port to peep. In theory this would intialise the first uart: spbrg = brg; //baud rate init txsta = 00100100b; //transmit init rcsta = 10010000b; //receive init and this would send a byte to the port while((txsta & 1 << TRMT) == 0); txreg = value; providing the fuses are set right but it doesnt. Even the microchip asm routines of 00774.zip does not work. Any other ideas.
  5. Thanx cac001, I copied the code as it is into boostc c and it refused to work. I have a hex file that came with the board and the chip. This send out a string at 9600,8,N,1. This works, but I cannot get this chip to work. Is there any other settings that you can think of?
  6. I had a look at your projects and then went to see what chips I had on hand. I don't have any 16F873's, though I do have 16F877's. I will pursue this further soon. But I also saw your LCD solution using a 16F628. I did have some of those lying around, so I burned your code into one and hooked it up to my displays to see if I had some bad parts, of if I am just cursed. I did determine that one older surplus LCD was at at best marginal, but when I hooked up to my better ones they worked fine. So your solution did at least give me confidence that my tools & parts are in spec, and whatever is bedeviling me is in the code. I would just do it your way, since it works well, but I want to use the 16F689 and a four bit interface to the LCD because I want to make a little backpack board with a choice of RS232, I2C, or SPI jumper selectable. I use I2C a lot more than RS232 and I have some good uses for an SPI device as well. Thanks for the suggestion & the project examples. How did anyone *ever* learn to do this stuff before the 'net? -- Dave W. [right][post=7793]<{POST_SNAPBACK}>[/post][/right]
  7. Hi, I tried to use on of the uarts on the pic18f8720. I have no success. After a while I took the code on this website and tried that! no success! I am using toolsuit boostc, MPLab 7.30 and icd 2 isp. Please have a look at the code anyone and comment. If I offended anyone by using your code, my apologies. #include <system.h> //Set clock frequency #pragma CLOCK_FREQ 20000000 #pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H #pragma DATA _CONFIG2L, _BOR_ON_2L & _BORV_27_2L & _PWRT_ON_2L #pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H #pragma DATA _CONFIG3L, _WAIT_OFF_3L & _MC_MODE_3L #pragma DATA _CONFIG3H, _CCP2MX_ON_3H #pragma DATA _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L #define USART_HW 0x01 #define USART_invert 0x02 #define USART_reset_wdt 0x04 #define spBAUD 9600 #define FOSC 20000000L #define fSPBCLK (FOSC) /* UART Baud rate generator clock (high speed) */ //#define fSPBCLK (FOSC / 4) /* UART Baud rate generator clock (low speed) */ #define SPBRG_VAL (fSPBCLK / (spBAUD * 16L)) - 1L // **** START OF DEFAULTS USED FOR SOFTWARE USART EMULATION **** #define TX_PORT 0xf82 #define TX_TRIS 0xf94 #define TX_BIT 6 #define RX_PORT 0xf82 #define RX_TRIS 0xf94 #define RX_BIT 7 #define e_SPBRG 0xfaf #define e_RCREG 0xfae #define e_TXREG 0xfad #define e_TXSTA 0xfac #define e_RCSTA 0xfab #define e_TXIF_PIR 0x4 #define e_RCIF_PIR 0x5 #define e_TXIF_BIT 4 #define e_RCIF_BIT 5 #define MODE (USART_HW) #if (spBAUD==115200) #define bit_time 43 // 115200 baud at 20MHz #endif #if (spBAUD==9600) #define bit_time 521 // 9600 baud at 20MHz #endif #if (spBAUD==600) #define bit_time 8333 // 600 baud at 20MHz #endif void Set_Red_LED( char c ); #include <rs232_driver.h> void interrupt( void ) { //Handle timer0 interrupt if( intcon & (1<<T0IF) ) { clear_bit( intcon, T0IF ); //clear timer 0 interrupt bit } } void main( void ) { //Configure port A trisa = 0x00; //Configure port B trisb = 0x00; //Configure port C trisc = 0x00; //Configure port h trish = 0x00; //Initialize port A porta = 0x00; //Initialize port B portb = 0x00; //Initialize port C portc = 0x00; //Set Timer0 mode set_bit( t0con, TMR0ON ); //enable timer0 clear_bit( t0con, T0CS ); //configure timer0 as a timer //Set Timer0 resolution set_bit( t0con, T08BIT ); //set timer0 8 bit wide //Set prescaler assignment clear_bit( t0con, PSA ); //prescaler is assigned //Set prescaler rate clear_bit( t0con, T0PS2 ); //prescaler rate 1:2 clear_bit( t0con, T0PS1 ); clear_bit( t0con, T0PS0 ); //Set timer0 source edge selection set_bit( t0con, T0SE ); //increment on high-to-low transition on RA4/T0CKI pin // for the hardware UART the paramter passed is the divisor // the hardware usart enables dynamic reconfiguration of the baud rate // the software emulated USART baud rate is defined by constants in // rs232_driver.h - this file also contains the address mapping for // RAM required to support the software emulated USART uart_init(1,SPBRG_VAL); // set high speed divisor mode and divisor value //Output test string into serial port putc( 'T' ); putc( 'e' ); putc( 's' ); putc( 't' ); putc( '\r' ); putc( '\n' ); Set_Red_LED(0); // turn off LED delay_ms( 250 ); Set_Red_LED(1); // turn on LED delay_ms( 250 ); //Endless loop while( 1 ); } void Set_Red_LED( char c ) { if (c > 0 ) { set_bit(porth,2); } else { clear_bit(porth,2); } }
  • Create New...