if is Write_decimal(data[i]), it gives value of 127230230230166102038230102102
if is number(data[i]), it gives value of 7000628022
why is it like that? It should've display 0000523066 right?
Im using PIC18F4520, MPlab C18.
this is my code:
- CODE: SELECT_ALL_CODE
#include <p18f4520.h>
#include <system4520.h>
#include <usart.h>
#include <stdio.h>
#include <delays.h>
unsigned char uart_rec(void);
unsigned char rfid_door[16]=" RFID Door ";
unsigned char security_sys[16]=" Security System";
unsigned char place_tag[16]=" Place your tag ";
unsigned char reader[16]=" on the reader ";
unsigned char id_no[16]={"ID: "};
unsigned char identified[16]="User Identified ";
unsigned char unidentified[16]="User not found! ";
unsigned char access_denied[16]="Access DENIED! ";
unsigned char opendoor[16]=" DOOR OPENED! ";
void main(void)
{
unsigned char i, database, cardid1, ID;
unsigned char id1[10]={0,0,0,0,5,2,3,0,6,6};
unsigned char ID1[16]={"0000523066"};
unsigned char data[12];
//USART INITIALISATION
OpenUSART(USART_TX_INT_OFF & //transmit interrupt off
USART_RX_INT_ON & //receive interrupt on
USART_ASYNCH_MODE & //asynchronous mode
USART_EIGHT_BIT & //8-bit data
USART_CONT_RX & //continuous reception
USART_BRGH_HIGH,25); //for baud rate 9600
lcd_init();
clear_screen();
cursor_set(0,0);
WriteS(rfid_door);
cursor_set(1,0);
WriteS(security_sys);
Delay10KTCYx(100);
while(1)
{
clear_screen();
cursor_set(0,0);
WriteS(place_tag);
cursor_set(1,0);
WriteS(reader);
for(i=0; i<12; i+=1)
{
data[i]=uart_rec();
}
clear_screen();
cursor_set(0,0);
WriteS(id_no);
cursor_set(0,3);
Write_Decimal(data[i]);
Delay10KTCYx(255);
}
}
unsigned char uart_rec(void) //receive uart value
{
unsigned char rec_data;
while(PIR1bits.RCIF==0); //wait for data
rec_data = RCREG;
return rec_data; //return the data received
}