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

LCD display Question marks(?) instead of card ID

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



Joined: 01 Apr 2011
Posts: 3

View user's profile Send private message

LCD display Question marks(?) instead of card ID
PostPosted: Fri Apr 01, 2011 4:38 am     Reply with quote

Hi,

I face problem in reading LCD display from RFID reader. There is nothing show when +5V is supply (should display "TEST"). Once i scan card on reader, 10 question marks are displayed.

S/W: PCWH compiler v4.038

H/W: PIC16f877a, 2x16LCD, RFID-IDR-232N (Baud rate:9600, 1 byte Start of heading (0x01), followed by 10 byte of ASCII character (ID) and 1 byte of Start of text (0x02))

Attach with my coding below:
Code:
#include <16F877A.h>
#fuses HS, NOWDT, NOPUT, NODEBUG, NOLVP, NOBROWNOUT, CPD, PROTECT, NOWRT
#use delay(clock = 20000000)
#include <FLEXLCD2.C>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#use fast_io(B)
#priority RDA

#define LCDlight     PIN_C1

//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#use RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, STREAM=COM_A)
#use rs232(baud=9600, xmit=PIN_D2, rcv=PIN_D3, STREAM=COM_B) //only PIN_D3 is connected)
#priority RDA
#zero_ram

int header, end, buffer[10]={}, counter=0;
int1 RFIDscan_fl=0;
////////////////////////////////////////////////////////////////////////////////

#INT_RDA              //RS232 receive data available
void isr_rs232(){

   header = getc();

   if (header == 0x01){

      while(counter<10){
         buffer[counter] = getc();
         counter++;
      }
      counter=0;

      end = getc();

      if(end == 0x02){
        RFIDscan_fl=1;
      }
   }
}

void checkIncomingData(){

 if(kbhit(COM_B)){
     if (fgetc(COM_B) == 0x01){
         while(counter<10){
            buffer[counter] = fgetc(COM_B);
            counter++;
         }
         counter=0;

         end = fgetc(COM_B);

         if(end == 0x02){
           RFIDscan_fl=1;
         }
     }

  }

}

void display_lcd(){
         lcd_putc("\f");
        lcd_putc(buffer[0]);
        lcd_putc(buffer[1]);
        lcd_putc(buffer[2]);
        lcd_putc(buffer[3]);
        lcd_putc(buffer[4]);
        lcd_putc(buffer[5]);
        lcd_putc(buffer[6]);
        lcd_putc(buffer[7]);
        lcd_putc(buffer[8]);
        lcd_putc(buffer[9]);
}

//###################################### main program started ##################


void main() {

   lcd_init();
   output_high(LCDlight);
   lcd_putc("  TEST     \n");
   delay_ms(1000);

  while (1) {
      checkIncomingData();
      if(RFIDscan_fl==1){
         display_lcd();
         RFIDscan_fl=0;
      }

  }
}//main()


Should i attach coding for FLEXLCD2.C?

Thanks!
temtronic



Joined: 01 Jul 2010
Posts: 9228
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 01, 2011 6:28 am     Reply with quote

couple of points....

delete the USE FAST_IO(B)..
..let the compiler handle the DDRs

add 'errors' to the USE RS232(..)..
..let the compiler handle the serial port

does the rfid reader connect via ttl or true RS232 ?
..if RS232, do you have a MAX232 or equal wired in right?


have you hooked up the reader to ,say , a PC and confirmed it works ?
maisy



Joined: 01 Apr 2011
Posts: 3

View user's profile Send private message

PostPosted: Fri Apr 01, 2011 8:56 am     Reply with quote

Thanks for your reply.
1) Due to the FLEXLCD2.C, i have to use fast_io(B).
http://www.ccsinfo.com/forum/viewtopic.php?t=24661


2) I have change to code as below:
Code:
#use RS232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, STREAM=COM_A, errors)
#use rs232(baud=9600, xmit=PIN_D2, rcv=PIN_D3, STREAM=COM_B, errors)


3)The rfid reader is connect to MAX232 through MCU, but MAX232 is not connected to PC. Actually i already test each of the module on breadboard. After they really work fine, then only i switch to PCB. I have check the connection so many times and should not be h/w problem.

4) I wonder why the lcd display nothing (even no black square,only back light is on) when i run the simple "LCD_display" programming that provided from PCM programmer. But whn i scan the reader, lcd can display question marks.
temtronic



Joined: 01 Jul 2010
Posts: 9228
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 01, 2011 9:18 am     Reply with quote

hmmm... I don't have FLEXLCD2.C driver, just the flexlcd.c driver and use standard_IO mode fine.


sounds like the LCD is not getting initialized or setup correctly then 'gets in sync' later.

might be quirk of the display you're using, or something different in lcd_init() from my version...
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 4:56 am     Reply with quote

maisy wrote:
Thanks for your reply.
1) Due to the FLEXLCD2.C, i have to use fast_io(B).
http://www.ccsinfo.com/forum/viewtopic.php?t=24661
From the specified thread:
Quote:
Disadvantages or Limitations:

1. This driver requires CCS "standard i/o" mode (The default mode
of the compiler). If you want to use fast i/o mode, then use the CCS
driver or Mark's driver:
I have not scanned all 7 pages of the linked thread, but I assume your FLEXLCD2.C file is the program listed at the top first page?
If yes, then you should not use fast_io.
maisy



Joined: 01 Apr 2011
Posts: 3

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 8:14 am     Reply with quote

Hi ckielstra,

Yaya, you are right! Thanks for your correction. I am so blur. However, the coding works fine on breadboard so i never suspect.

After re-wire hardware and found that no voltage supply to LCD. But i wonder why LCD can perform blinking function and display question marks without voltage supply.

All,

Now, my project work as expected. Sorry in wasting your time for my careless mistake. Thanks for all replies Smile However, I have learn a lot from this forum throughout the issue. This forum is awesome!
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Sat Apr 02, 2011 10:08 am     Reply with quote

With almost all IC's, there are either deliberately for protection, or 'accidentally' because of the structure of the gates involved, effectively diodes on the input lines, that prevent an incoming signal, from going significantly above the devices 'supply'. Because of this, if you connect such a device, that does not need too much power, to a series of logic lines carrying signals, while leaving the supply disconnected, the signals will tend to 'pump' the rail inside the device up, often to the point where it'll start to work. If there is some capacitance attached to the device, this allows the 'gaps' in the signals to be bridged. 'Partial' operation, can then result. How well it'll actually work, will depend on the available current on the signals, the exact pattern of the signals, the consumption of the device, luck, etc....
So the processor was actually supplying the power for your LCD, with slightly 'indeterminate' results....

Best Wishes
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