Searching \ for '[PIC]:help with hi-tech code and building librarys' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'help with hi-tech code and building librarys'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:help with hi-tech code and building librarys'
2001\08\13@235116 by James Fitzsimons

flavicon
face
part 1 1327 bytes content-type:text/plain; (decoded 7bit)

Hi all,
I am a total PIC newbie and have a couple of questions.
I am trying to develop my first PIC project in Hi-tech C.

I want to create a library using the delay.c delay.h and iserial.c
(attached) files. The problem is I can't create the .obj file for the
iserial.c file as I keep getting the following errors.

Warning[000 ] file
c:\mydocu~1\personal\robotics\picstu~1\librarys\serial~1\iserial.c  114 :
arithmetic overflow in constant expression
Warning[000 ] file
c:\mydocu~1\personal\robotics\picstu~1\librarys\serial~1\iserial.c  162 :
arithmetic overflow in constant expression

I can see that the code is trying to set the timer to a negative value, but
don't understand why? Could anyone give me any pointers here.

Secondly, the iserial.c file contains an interrupt routine. This is pretty
much my first time dealing with interrupts, but from reading the hi-tech
picc lite manual I see that you can only have one ISR on the 16F84. This
leads me to the question, what happens if you are expecting interrupts from
multiple sources eg. timer, pins, etc... Is it best to just build one huge
ISR and use a switch statement (or something similar) to execute the
appropriate part depending on what caused the interrupt?

Thanks for any help you can provide!

Regards,
James Fitzsimons


part 2 7231 bytes content-type:application/octet-stream; (decode)

part 3 136 bytes
--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2001\08\14@073449 by Spehro Pefhany

picon face
At 03:41 PM 8/14/01 +1200, you wrote:

>I can see that the code is trying to set the timer to a negative value, but
>don't understand why? Could anyone give me any pointers here.

Probably a problem with the delay routine. Can you declare something as
"unsigned" to get the range you need? ISTR that there are problems with the
supplied delay routines for some clock frequencies (but I think for >4MHz).

>Secondly, the iserial.c file contains an interrupt routine. This is pretty
>much my first time dealing with interrupts, but from reading the hi-tech
>picc lite manual I see that you can only have one ISR on the 16F84. This
>leads me to the question, what happens if you are expecting interrupts from
>multiple sources eg. timer, pins, etc... Is it best to just build one huge
>ISR and use a switch statement (or something similar) to execute the
>appropriate part depending on what caused the interrupt?

Just poll the expected flags in the ISR..

interrupt void isr(void)
{
 if (INT_FLAG1)
   {
   ...
   INT_FLAG =0;        // reset the interrupt flag for this source
   }
 if (INT_FLAG2)
   {..
   INT_FLAG2=0;        // reset the interrupt flag for this source
   }
}

Primitive, yes, but remember the early PICs didn't have interrupts at all.
8-(

Best regards,

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Spehro Pefhany --"it's the network..."            "The Journey is the reward"
.....speffKILLspamspam@spam@interlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com
Contributions invited->The AVR-gcc FAQ is at: http://www.bluecollarlinux.com
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2001\08\14@073503 by Brent Brown

picon face
Hi James,

Sorry I can't help with your first question straight away, but the
second one you're on the right track. There is only one interrupt
vector so you need to check each flag to see what needs servicing
(might be more than one). Typically I use a bunch of if() statements
in the ISR to check the various flags:-

//--------------------------------
void interrupt IntRoutine(void){

  // Timer1 overflow ------------
  if(TMR1IF){
     TMR1IF=0;
     TMR1H = TMR1H | 0xFC;
     TMR1L = TMR1L | 0x68;
     tick=1;
  }

  // TMR2IF ---------------------
  if(TMR2IF){
     TMR2IF = 0;
  }

  // RB0/INT --------------------
  if(INTF){
     INTF = 0;
  }
}


Brent Brown
Electronic Design Solutions
16 English Street
Hamilton, New Zealand
Ph/fax: +64 7 849 0069
Mobile/text: 025 334 069
eMail:  .....brent.brownKILLspamspam.....clear.net.nz

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...