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 CCS Technical Support

PIC87J50 and RS232 (#INT_RDA)

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PIC87J50 and RS232 (#INT_RDA)
PostPosted: Fri May 27, 2011 7:18 am     Reply with quote

Hello,
I had some code working on a PIC18F4550 and want to use this on a PIC87J50...
It is a device which send some data at 9600 baud to the PIC.
So far no problem.. Test the device (RFID reader the ID20) and with the PIC18F4550 it works.
Connect it to the PIC87J50 and it isn't been able to pull the line down.
When the PIC isn't running I can see (at the scope) that there is data tranmitted. but when the PIC starts it can't pull the line low....?? I see that there is some data trying to be transmitted but it stays between the 3V and the 3,3V .....
What am I doing wrong with the setting....?????
Included the code and the header file..
Compiler version: 4.119

Checking if there is incoming data is done by setting a breakpoint at the interrupt routine. Using a ICD2...

Anybody anyclue????

Regards,
Jody

Code:

#include <main.h>
#include <stdlib.h>
#include <string.h>
#include <input.c>
#include <LCD_CCS.c>

int              string_ready                    = 0;
signed int      next_in               = 0;
char            string[20];
char            string_lengte[8];
char            RFID[5];
int8            first               = 1;
int8            lengte_string         = 0;



#int_RDA
void  RDA_isr(void)
{
 string[next_in]=fgetc(ID20);
  if((string[next_in] == 0x0D) & (next_in > 1))   //Einde string
  {
    string_ready = 1;
    string[next_in+1] = '\0';
   next_in = 0;
  }
  next_in=(next_in+1);
  if(next_in > 20) next_in = 0;
}


void main()
{
   setup_timer_4(T4_DISABLED,0,1);
   setup_oscillator(OSC_32MHZ|OSC_NORMAL|OSC_31250|OSC_PLL_OFF);

   setup_uart(TRUE);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);

   lcd_gotoxy(1,1);
              printf(lcd_putc, "Test RS232");
             delay_ms(5000);

   while(1)
   {
   if(string_ready == 1)
   {
      lcd_gotoxy(1,1);
       printf(lcd_putc, "Papagaai gezien!");
   }
   }
}

Code:

#include <18F87J50.h>
#device ICD=TRUE
#device adc=16

#FUSES INTRC_PLL
#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES DEBUG                    //Debug mode for use with ICD

#use delay(clock=32000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=ID20)

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri May 27, 2011 4:52 pm     Reply with quote

Post a list of the connections between the ID-20 board and your PIC.
Post the pin numbers on each device that are connected to each other.
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Mon May 30, 2011 1:43 am     Reply with quote

ID-20, pin 8, I have connected to a level converter (MAX232) pin 13 (R1IN).
MAX232 pin 12 (R1OUT) goes to pin 37 of the PIC87J50 and this is TX1, so that's wrong (I think). I have changed this into pin 38 that's RX1.
My interrupt is firing but the correct data isn't received. Now I have a oscillator settings mistake I think.

Thanks for the help!!!
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon May 30, 2011 8:37 am     Reply with quote

Well string_ready is initialized (cleared) and when the ISR fills it and gets an end of line char it is set. The main routine never resets ( clears) it to the initial condition after displaying it on the LCD. Now perhaps the lcd_put routine resets it so it isn't an issue. The other issue might be that an LCD takes some time to to get itself ready for receiving commands ..there is no provision for this in the code above.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 30, 2011 11:33 am     Reply with quote

I can't really help much more on this, because the data sheets for the
ID-12 and ID-20 are not clear on the polarity of the output signals.
For example, on this Sparkfun forum page, they say the data sheet is
incorrect. The so-called "TTL inverted" signal is not really inverted:
http://www.sparkfun.com/products/8419

If I was writing the ID-12/20 data sheet, I would nail everything down
exactly. I would show sample output waveforms for say, the character 'A'.
I would show the start bit, 8 data bits and the stop bit. I would show the
voltage levels. I would do this for both the Data 0 and Data 1 pins of
the ID-12/20. I would make everything completely obvious.
But they didn't do that, so I don't want to do anything more on this project.
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