Timeline for UART on PIC16F1829 - RCIF Interrupt for RX pin not working, cannot receive anything even with polling
Current License: CC BY-SA 3.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 10, 2017 at 13:52 | history | edited | Dave Tweed | CC BY-SA 3.0 | Move solution to answer |
| Sep 10, 2017 at 8:50 | history | edited | JRE | CC BY-SA 3.0 | edited title |
| Sep 10, 2017 at 5:08 | vote | accept | humanistscience | ||
| Sep 10, 2017 at 5:08 | answer | added | humanistscience | timeline score: -1 | |
| Sep 10, 2017 at 4:12 | comment | added | Kevin Reid | Please post your solution as an answer (and accept it) instead of editing the question. That way it is properly marked as answered. | |
| Sep 10, 2017 at 3:03 | history | edited | humanistscience | CC BY-SA 3.0 | solved |
| Sep 10, 2017 at 3:02 | comment | added | humanistscience | Thank you everyone. I have solved the problem and posted my working code. | |
| Sep 5, 2017 at 12:35 | comment | added | humanistscience | I re-wrote the code last night to test if RCIF is ever triggered, just turn the LEDs on. Didn't work. So for some reason RCIF is not triggering. | |
| Sep 5, 2017 at 12:34 | comment | added | humanistscience | I originally had tried to get it going as interrupt driven but it was never entering the ISR. I just wanted to see if it could be read by polling, but it seems RCIF never returns a 1 no matter how I read it. | |
| Sep 5, 2017 at 4:15 | comment | added | Dan Laks | Also, you're adding extra complexity with your functions that read the serial data, write it back, then blink an LED. Since you're new to this, simplify it. Have it just turn on the LED if the receive flag (RCIF) goes high. If you can get that to work, then add one more later of complexity, and so on. Get rid of the functions for now until you can prove you can get the basic stuff working. | |
| Sep 5, 2017 at 3:52 | comment | added | Dan Laks | A quick glance at your code without deep diving into it. You've enabled interrupts with GIE, PEIE, RCIE, and TXIE, but your interrupt function is commented out. So if serial data is arriving on the RX pin, the processor is jumping to the designated interrupt memory location, but there's no instructions there. That is fatal. You shouldn't be dabbling in interrupts anyway if you're new to this MCU. | |
| Sep 5, 2017 at 1:31 | comment | added | Reinderien | If you replace your entire main loop with RA5 = RCIF; and put a scope on RA5, does it ever change? | |
| Sep 5, 2017 at 1:08 | comment | added | humanistscience | Reducing startup time is the least of my concerns. Do you actually have any idea about the question I asked? What specifically is wrong with my code that RCIF is not firing under any circumstances, through polling or interrupts, and thus my RX pin does nothing. | |
| Sep 5, 2017 at 1:00 | comment | added | Reinderien | The following will be reduced to 2 (if I remember correctly) machine instructions for each statement: PIE1 |= _PIE1_RCIE_MASK | _PIE1_TXIE_MASK | _PIE1_ADIE_MASK; RCSTA = _RCSTA_SPEN_MASK | _RCSTA_CREN_MASK; TXSTA = _TXSTA_TXEN_MASK | _TXSTA_BRGH_MASK; (and so on) | |
| Sep 5, 2017 at 1:00 | history | edited | humanistscience | CC BY-SA 3.0 | deleted 7 characters in body |
| Sep 5, 2017 at 0:49 | comment | added | humanistscience | Can you give an example of what you mean Reinderien by "rewrite some of your register bit assignments as OR combinations" | |
| Sep 5, 2017 at 0:19 | comment | added | Reinderien | For better assembly, you should rewrite some of your register bit assignments as OR combinations of the flag macros from the header. | |
| Sep 5, 2017 at 0:17 | comment | added | Reinderien | Your reference to PIR1bits shouldn't be necessary either. | |
| Sep 5, 2017 at 0:15 | comment | added | Reinderien | What's with all of the 5ms delays? Surely most or all of them shouldn't be necessary. Also, do you have the paid or free version of MPLAB? The free version won't optimize down those one-line functions. You're better off declaring them as macros. | |
| Sep 4, 2017 at 17:10 | history | asked | humanistscience | CC BY-SA 3.0 |