CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

serial funnies 16f88x vs 16C74x

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

serial funnies 16f88x vs 16C74x
PostPosted: Tue Dec 22, 2009 4:29 pm     Reply with quote

I have some 16C74 A & B chips - they BOTH show the same problem.

If you comment out the two 16c74 related lines && compile for the 887 (or even 877) - the code works perfectly and echoes all data arriving perfectly.
At baud rates from 4800 to 76800 - perfection. This was designed to find the fastest safe baud rate for the 74 family - to try to use up a stockpile of a few thousand new (otherwise surplus) 74A's and B's on a cost sensitive product.
BTW: the host uses a crystal controlled TI 16550 UART with dead on clock accuracy and the 887 in the same test fixture can loop back data flawlessly @ 76800 baud without a single error char for 48 hours non stop using this code !!

Yes I know there is an error warning on the c74 family above, 9600 baud but when compiled even at 4800 baud - the greeting is always output - but no receive data is ever echo'd with the C74 -
the LST file is not very illuminating 2 me - and I think I must have missed something obvious - but damned if I can tell. I can't even see WHERE the compiler is setting BRGH or NOT, since it does not seem associated with the setup of USART services !!!
Does anybody have a clue ?
Code:

// #include <16f887.h>
// #FUSES NOPROTECT,NOMCLR,HS,NOWDT,NODEBUG,NOLVP,NOIESO,NOFCMEN,PUT,NOWRT,NOFCMEN
#include <16c74a.h>
#Fuses HS,NOWDT,PUT,NOPROTECT,BROWNOUT
#include <stdlib.h>
#use delay( clock=4915200)
#use fast_io(C)

#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS )
#define BUFFER_SIZE 48
BYTE RISR_out;      // global background newchar from ISR BACKGND buffer
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;
// interrupt receiver code
#define bkbhit (next_in!=next_out)
// I ONLY call if bkbhit is true
void bgetc(void) {
   RISR_out=buffer[next_out];
   next_out=(next_out+1) % BUFFER_SIZE;
}

void DISR_INIT(void){
    clear_interrupt( int_rda );
    enable_interrupts(int_rda);
    enable_interrupts(global);
}
#int_rda
   void serial_isr() {
   int t;
   buffer[next_in]=getc();
   t=next_in;
   next_in=(next_in+1) % BUFFER_SIZE;
   if(next_in==next_out)  next_in=t;           // Buffer full !!
}
//***********************************
void InitHDW ( void ) {
//***********************************
 
     set_tris_c (128); // set bit 7 per datasheet for C7=INPUT
     DISR_INIT();
}
//===================================
void main() {
    InitHDW();     printf ("*Hello*\r");  // just check output
    while (1) {           // now get AND send at same time
          if (bkbhit)   { bgetc(); putc(RISR_out);}  //simple test
    }  //         END : while  1
}
//
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Dec 22, 2009 4:59 pm     Reply with quote

See this post on the Microchip forum:
http://www.microchip.com/forums/tm.aspx?m=15688&mpage=1


Also, what is your compiler version ?

Have you tried it with a different crystal frequency (say, 8 MHz) ?
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Dec 22, 2009 9:26 pm     Reply with quote

ver 4.066 --
did not try 8 MHz - and may not now -

I used the 4.9152mhz ( plug in 14 pin OSC can - have 10K in inventory )
because it gives perfect divisors with BRGH=0 up to 76800

I thought based on the baud rate that staying with a zero error baud
master freq was desirable - now I'm tempted to use a software RX channel instead on the B port INT pin.
BTW - I had the exact SAME problem of NO work at all with the 16c65A - which I have quite a few of ( too many I think ) too - and it sucks just as bad.

Because this is a new limited production design - I have total flex with the circuit design and software - & my boss would LOVE 2 use up these parts - AND its being serial/ USB translated with an FTDI UM232R - plus baud rate not critical - I can go down to 2400 baud and still be fine..
The TX side hardware is A-ok.

I had HOPED there was some software glitch - because finding SOME bad chars was one thing -but NO hardware RX at ALL - really sucks!

Thanks PCM 4 the concise link to the bad new s;-))
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group