peter_pvk 0 Posted December 12, 2009 Report Share Posted December 12, 2009 Greetings, I'm trying to compile the code given below for the 16F886 or 16F917. With the 4 lines commented out as shown, the build completes and functions as expected. If I uncomment the 4 lines, I get a message of "xxx.bas(7): error: general error" 1. What is a "general error" ? 2. How can I fix it? Thanks, Peter ............................ #pragma CLOCK_FREQ 4000000 sub main() dim i as byte dim v(70) as byte if v(2) = 80 and v(3) = 82 then for i = 5 to 58 v(i) = (call usart_rx()) next ' else if v(2) = 80 and v(4) = 71 then ' for i = 59 to 68 ' v(i) = (call usart_rx()) ' next end if loop1: goto loop1 end sub function usart_rx() as byte if ( (rcsta.OERR = 1) ) then rcsta.CREN = 0 rcsta.CREN = 1 usart_rx = 0x00 else do while (pir1.RCIF = 0) _asm nop loop usart_rx = rcreg end if end function Quote Link to post Share on other sites
Dave 0 Posted December 12, 2009 Report Share Posted December 12, 2009 Peter_pvk. 1. What is a "general error" ? When the compiler finds an error in the code and it has no further breakdown of what the error might be. As time goes in the development of the compiler the more errors, where possible, get improved error messages. 2. How can I fix it? Remove the space between else and if, ie "else if" becomes "elseif". See below: #pragma CLOCK_FREQ 4000000 sub main() dim i as byte dim v(70) as byte if v(2) = 80 and v(3) = 82 then for i = 5 to 58 v(i) = (call usart_rx()) next elseif v(2) = 80 and v(4) = 71 then for i = 59 to 68 v(i) = (call usart_rx()) next end if loop1: goto loop1 end sub function usart_rx() as byte if ( (rcsta.OERR = 1) ) then rcsta.CREN = 0 rcsta.CREN = 1 usart_rx = 0x00 else do while (pir1.RCIF = 0) _asm nop loop usart_rx = rcreg end if end function Regards Dave Quote Link to post Share on other sites
peter_pvk 0 Posted December 12, 2009 Author Report Share Posted December 12, 2009 I knew it was going to be simple... and sure enough... I'm going to learn to read Real Soon Now. Thanks, Peter Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.