Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Collision between USART data and Port Pin operation

Status
Not open for further replies.

speedEC

Full Member level 6
Full Member level 6
Joined
Apr 1, 2011
Messages
337
Helped
23
Reputation
46
Reaction score
21
Trophy points
1,298
Activity points
4,324
Hello All,
I am facing a problem in accessing Barcode Scanner data. I am using PIC24FJ... uC for communicating with USB Barcode Scanner. Everything works fine as expected but with one issue. I am using PIC16F... uC.

PIC16F... (RX PIN) <- PIC24FJ... <- USB Barcode Scanner (ONLY INCOMING DATA. NO OUTGOING TO SCANNER. SO TX PIN NOT USED).

I can able to receive data from Scanner. If data received, I am validating the data. If valid data do some process. If Invalid data send Error message thru' BEEP sound for 3 seconds. Here the problem starts. If I show barcode label in front of scanner while uC sound BEEP, i.e. within the 3 seconds period, error occurred. I am receiving some digits and code hanged some where else.

Usually what I do is, disable USART and re_enable USART after process is completed. I tried that method here. But, scanner shuts down and restart everytime disable & reenable USART. I have not write code for PIC24FJ... (for USB scanner). I bought the board from ebay.


Code C - [expand]
1
2
3
4
5
6
unsigned char getch() {
    /* retrieve one byte */ 
        while(!RCIF)    /* set when register is not empty */
        continue;
    return RCREG;
}




Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
if (ERROR_1){
    printf("\r\n%s\r\n",ERROR);
    BAD_READ_LED = 1;
    ERROR_BEEP();  [B][I][COLOR="#FF0000"]// 3 seconds (if we show barcode label, while code runs here, Coliision occurs here?!)[/COLOR][/I][/B]
    BAD_READ_LED = 0;
    ERROR_1 = 0;
}
else{
    printf("\r\n%s\r\n",OK);
    GOOD_READ_LED = 1;
    OK_BEEP();
        GOOD_READ_LED = 0;
}



disableUSART and ReenableUSART functions;

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
void disableRX(void){
    TRISC7 = 0;// RX PIN AS OUTPUT
    SPEN = 0;
    CREN = 0;
}
void re_enableRX(void){
    TRISC7 = 1;// RX PIN AS INTPUT AGAIN
    SPEN = 1;
    CREN = 1;
}



How can I solve this issue?

thank you all
 

This makes no sense. If you are not using the TX from the PIC16 to the scanner, how does the scanner know you've disable the USART? If the TX signal is "not used" but is actually connected, perhaps when you disable/enable the USART the TX pin, the pin is changing state. Maybe it goes tristate?
 

This makes no sense. If you are not using the TX from the PIC16 to the scanner, how does the scanner know you've disable the USART?
PIC16F... not connected directly to scanner. Connected thru' PIC24FJ... only. Scanner data sent to PIC16F only from PIC24FJ... PIC24FJ takes care of communicatiing with scanner and retrieve data. Why do we use PIC24FJ... is only for USB host to communicate with scanner.
 

You're not giving us complete information. Does the PIC16 TRANSMIT to the PIC24? Again, how does the scanner know that the USART is disabled? Maybe a diagram would make this a little clearer.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top