1
\$\begingroup\$

I am trying to use enable USART communication on a PIC18F6722 microcontroller. More specifically enable the receiver and attach a receive interrupt to it.

The datasheet describes the relevant bits as such

RC2IE: USART2 Receive Interrupt Enable bit
1 = Enables the USART2 receive interrupt
0 = Disables the USART2 receive interrupt

CREN: Continuous Receive Enable bit Asynchronous mode:
1 = Enables receiver
0 = Disables receiver

For some reason this piece of code doesn't do it though:

PIE3bits.RC2IE = 1; 
RCSTA2bits.CREN = 0;

I want to set both of these to 1 although it isn't working. Any ideas?

I previously asked a similar question although I didn't get any useful information

\$\endgroup\$
6
  • 2
    \$\begingroup\$ It'd be worth posting some more complete code that includes your interrupt handler and other USART init code. \$\endgroup\$
    – PeterJ
    Jul 14, 2014 at 2:50
  • \$\begingroup\$ @PeterJ I already post my question thanks in advance \$\endgroup\$ Jul 14, 2014 at 3:01
  • 1
    \$\begingroup\$ Why are you posting again when your linked question already has answers? \$\endgroup\$
    – Funkyguy
    Jul 14, 2014 at 3:02
  • \$\begingroup\$ @ShannonStrutz i didn't get any useful information \$\endgroup\$ Jul 14, 2014 at 3:06
  • \$\begingroup\$ @user3732308 okay well I have edited the question to make it much more reader friendly. \$\endgroup\$
    – Funkyguy
    Jul 14, 2014 at 3:18

1 Answer 1

1
\$\begingroup\$

You need to enable global interrupts (GIE) and peripheral interrupts (PEIE). Check out register 10-1 (INTCON) and figure 10-1 in the datasheet. Without them, your interrupt will never happen.

enter image description here

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.