Darrel,
Any obvious reason why this program takes over 10 seconds to start up on a PIC 18F4550?
If I comment out the Interrupt settings at the top (includes and asm) and the ReceiveUSART handler further below, it takes less than 2 seconds.
Robert
![]()
Darrel,
Any obvious reason why this program takes over 10 seconds to start up on a PIC 18F4550?
If I comment out the Interrupt settings at the top (includes and asm) and the ReceiveUSART handler further below, it takes less than 2 seconds.
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Not sure about this, but gotta start somewhere.
The RX_INT is being ENABLEd before the USART registers are set-up. Or, more accurately, since HSERIN/OUT are used in the program, PBP initializes the USART first, then RX_INT is enabled, then the USART registers are changed.
It may be causing a false interrupt that sends it to the ReceiveUSART: handler, which is expecting to see 2 bytes being received, that were never sent. So it sits there.
Try using this...In place of..Code:DEFINE HSER_CLROERR 1 ' Hser clear overflow automatically DEFINE HSER_RCSTA 90h ' Hser receive status init DEFINE HSER_TXSTA 24h ' Hser transmit status init DEFINE HSER_SPBRG 0 ' Hser spbrg init While PIR1.5 = 1 ; clear the buffer HSERIN [varByte] Wend @ INT_ENABLE RX_INT ; enable RX interruptsCode:@ INT_ENABLE RX_INT ; enable RX interrupts DEFINE HSER_SPBRG 0 ' 1250 KBAUD @ 20 MHz (CPU) BAUDCON.3 = 0 ' BRG16 Select 8 bit baud rate generator TXSTA.5 = 1 ' TXEN Enable USART transmitter TXSTA.4 = 0 ' SYNC Asynchronous communication TXSTA.2 = 1 ' BRGH High speed baud rate RCSTA.7 = 1 ' SPEN Enable USART receiver RCSTA.4 = 1 ' CREN Enable continuous receive
DT
Nope, wasn't it. But as I was putzing around trying other stuff I noticed a few attempts were within 2 seconds, but for no apparent reason. For some reason it appeared to be an unstable setup and I remembered that unset pins can do this. And that's when I remembered this from page 235 of the 18F4550:
-----------------------------------------------------------------------
The pins of the Enhanced USART are multiplexed with
PORTC. In order to configure RC6/TX/CK and
RC7/RX/DT/SDO as a USART:
• bit SPEN (RCSTA<7>) must be set (= 1)
• bit TRISC<7> must be set (= 1)
• bit TRISC<6> must be cleared (= 0) for
Asynchronous and Synchronous Master modes
or set (= 1) for Synchronous Slave mode
-----------------------------------------------------------------------
I had ignored this paragraph 'cause I had never seen a need for these resistors, I thought it was only for the Enhanced USART. So I added the 4K7 resistors on TX (pulldown) and RX (pullup) and everything works fine, even with my old code.
Thanks D!
Robert
![]()
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Well, I misunderstood what I was supposed to do but when I removed the resistors and put in the TRIS statements it took 9 seconds again. So I set the port pins to 0, same thing, I set them to 1, same thing.
It works properly with just the 4K7 resistors.
EDIT: I tried pulling both pins down and that works as well.
Robert
![]()
Last edited by Demon; - 23rd July 2006 at 16:34.
My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.
Not as dumb as yesterday, but stupider than tomorrow!
Bookmarks