CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Help please no interrupt works

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
technoclue



Joined: 24 Jul 2012
Posts: 3

View user's profile Send private message

Help please no interrupt works
PostPosted: Wed Jul 25, 2012 3:51 pm     Reply with quote

have the following test example:
Code:

#include <usb_bootloader.h>
#include <18F2550.h>
#device adc=8
#FUSES NOWDT                    //No Watch Dog Timer
//#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                    //High Speed Crystal/Resonator with PLL enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT               //brownout reset
//#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES PUT                    //Power Up Timer
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP
#FUSES NOPBADEN                   //PORTB pins are configured as digital #FUSES WRTB                   //Boot block is write protected
#FUSES PLL5                    //Divide By 5(20MHz oscillator input for 48Mhz)
#FUSES CPUDIV1                  //System Clock by 1 for 48Mhz
#FUSES USBDIV                   //USB clock source comes from PLL divide
#FUSES VREGEN                   //USB voltage regulator enabled

#use delay(clock=48000000)

#define LED1 PIN_A4

BYTE blink = 0;

#int_rb
void button_isr() {
   delay_ms (20);  //debounce
   if( !input(PIN_B4) && !blink )
      blink = 1;
   else if( !input(PIN_B4) && blink )
         blink = 0;
}

void main() {
set_tris_b(0b11111111);

   enable_interrupts(global);
   enable_interrupts(int_rb);
   ext_int_edge( H_TO_L );

   do {
      if(blink){
         output_high(LED1);
         delay_ms(500);
         output_low(LED1);
         delay_ms(500);
      }
   } while (TRUE);
}


Using CCS v4 none of any interrupt works, what is going on?
Can anybody help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 25, 2012 4:07 pm     Reply with quote

It works for me. I tested it in hardware with an 18F4550 (same PIC family)
with vs. 4.135. Have you ever made the PIC do anything, such as
blinking an LED ? Do you know that the PIC works ?

Is this a real hardware project or Proteus ?

Quote:
Using CCS v4

That's not a version number. These are version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
You know this.
technoclue



Joined: 24 Jul 2012
Posts: 3

View user's profile Send private message

PostPosted: Wed Jul 25, 2012 5:55 pm     Reply with quote

Quote:

Have you ever made the PIC do anything, such as
blinking an LED ? Do you know that the PIC works ?

Yes I have. I tried making LED1 to blinking in loop if the port PIN_B4 detects high and it works meaning B4 is set correctly and LED1 outputting, what else I could try? Tried to test uart, spi on PIC they work fine using same compiler.

Note: I use FS USB Demo tool for boot loader, the PIC18LF2550 is loaded with generic FSUSB boot loader so above fuses only works/compatible with it.
* CCS version v4.074, i doubt has to do with this problem.
* Hardware is on PCB and well designed to eliminate connection issues.
* Same PIC used with code using C18 compiler of Ext and pin change and timers all working..
* used the wizard to try to make only timer0 to setup and I found it is also does not function. I noticed INT_RB will not pass to next functions below
at enable_interrupts(GLOBAL);
while timer0, INT_EXT would pass/continue but still does not function.

I hope these info would pinpoint what is going on.

Quote:
Is this a real hardware project or Proteus ?

Yes it is a real HW on tested PIC. PIC powered by USB same link for bootloader, power verified to be accurate.

I edit this post several times to reflect few tries. I changed the PIC18LF2550 with PIC18F2550 and the same behavior occurs. I'm really baffled with this issue. Could it be a bug with CCS in development env. of Microchip generic bootloader driver?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 1:39 pm     Reply with quote

I tested the program with vs. 4.074 and it also works OK.

I am not using your exact same test setup. Here are the differences:

1. I'm using 18F4550 instead of 18F2550, but that shouldn't make any difference.

2. I have an external 4.7K pull-up resistor on Pin B4. A pull-up is
essential to make pin B4 have the ability to go between a logic '1' and
a logic '0' level. I have a jumper wire connected to pin B4. When I
touch it briefly to ground, it puts a logic '0' on pin B4. When I remove
the wire, pin B4 goes to a '1' level. This is how I test the program.
I tap the wire to ground once, and the LED starts blinking. Then when
I tap it again, the LED stops blinking.

3. I am not using usb_bootloader.h, instead I am using ICD3 to program
the 18F4550. I commented out the usb_bootloader.h line at the top.
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 3:08 pm     Reply with quote

I wonder if the key is the position of usb_bootloader, and the fact that PCM_programmer is not using this.

Generally, the processor include, _must_ be before anything else.

I'd change the layout to have:

Processor include
any other #device lines
Fuses
clock settings
Then the bootloader include.
Global variables.
Then other includes
Then the other code

I'm not _sure_ for example, that the getenv function works correctly, before the processor is defined?.

Try with the standard layout, and see if things start working.

Best Wishes
technoclue



Joined: 24 Jul 2012
Posts: 3

View user's profile Send private message

PostPosted: Thu Jul 26, 2012 5:32 pm     Reply with quote

Ttelmah wrote:
I wonder if the key is the position of usb_bootloader, and the fact that PCM_programmer is not using this.

Generally, the processor include, _must_ be before anything else.

I'd change the layout to have:

Processor include
any other #device lines
Fuses
clock settings
Then the bootloader include.
Global variables.
Then other includes
Then the other code

I'm not _sure_ for example, that the getenv function works correctly, before the processor is defined?.

Try with the standard layout, and see if things start working.

Best Wishes


I have the usb bootloader include comes just after the processor include, so the processor directive is the very first thing here.

PS. (PCM P..) You must had set the usb_boot.. below the 18F2550.h, do not you?
Because the compiler will complain #device expected. I had mistakenly set the code above...

I'm successfully running on this PIC SPI, Serial, SD Card access, ADC,.. but non of timers, int_ext or int_rb. I have discovered that putting 4.7K ohm on RB4 as "PCM ..." said will cause pressing long on Reset MCLR button will only Re-run the PIC and not getting into the bootloader. This indicates there maybe RB4 is originally set as the USB Sense on the bootloader, could be set as Boot button and only when this button set low the reset will activate the bootloader mode. So I'll use RB5,..RB7 for testing till I confirm by going into bootloader original code of what is RB4 is doing.

I checked the usb_bootloader header and could not find a relation to the interrupts part of it. I really appreciate if someone could direct me to an alternative to FS USB Demo BL, maybe using HID bootloader/ Serial what to use. I know previously I used Serial BL for 18F877 but it is not for 2550, and I do use HID BL but for the J series such as 18F26J50 which pic compatible with 2550 (may be you say why I do not use this darn thing instead) because the darn V4.047 does not support 26J50 so I do not have a device/header for it. Otherwise it would be much better.. I appreciate if someone share with me the HID bootloader if he/she has. I could compile the one came with michrochip solutions for 2550.

Please update me as soon as you can, thanks to all..
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group