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 support@ccsinfo.com

PIC18F4550 USB CDC port b1 is not going high

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PIC18F4550 USB CDC port b1 is not going high
PostPosted: Thu Feb 17, 2011 6:59 am     Reply with quote

Hello,
compiler version: 4.078

What works: USB connecting to the PC working perfect.
When a IC is pulling mine B1 pin high, the PIC is keeping it low... I have no idea what I am doing wrong....
What I tested: IC without PIC is going high and low like it should.
Replaced the IC...
Replaced the PIC.. and always it work except when I connect the PIC and IC together. I have the same IC on different pins.. like B0 and B2, and this works...

Included code:

Code:

#include "C:\MentorProjects\Sensa\PIC_CODE\Sensa.h"
#include <stdlib.h>
// Includes all USB code and interrupts, as well as the CDC API
#include <usb_cdc.h>
#include <float.h>
#include <string.h>

#define  B0      PIN_B0
#define  B1      PIN_B1
#define  B2      PIN_B2
#define  B3      PIN_B3


void main()
{
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   usb_cdc_init();
   usb_init();

    while(1)
    {
      while(!usb_cdc_connected())
        {
         }
        usb_task();
        if (usb_enumerated())
        {
         if(input(pin_B1))
         {
         printf(usb_cdc_putc,"A");
         };
         if(!(input(pin_B1)))
         {
            delay_ms(400);
            if(!(input(pin_B1)))
            {
               printf(usb_cdc_putc,"a");
            }
         };
            }
  }


Code:

#include <18F4550.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES WDT128                   //Watch Dog Timer uses 1:128 Postscale
#FUSES HSPLL                      //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES BORV20                   //Brownout reset at 2.0V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES DEBUG                    //Debug mode for use with ICD
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                     //Internal External Switch Over mode enabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES NOPBADEN                 //PORTB pins are configured as digital I/O on RESET
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES MCLR                     //Master Clear pin enabled
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES PLL5                     //Divide By 5(20MHz oscillator input)
#FUSES CPUDIV1                  //System Clock by 2
#FUSES USBDIV                   //USB clock source comes from PLL divide by 2
#FUSES VREGEN                   //USB voltage regulator enabled
#FUSES NOICPRT                    //ICPRT enabled

#use delay(clock=20000000)
#use STANDARD_IO(B)
#use rs232(baud=2400,parity=N, stop =1,xmit=PIN_C6,rcv=PIN_C7,bits=8)


Ttelmah



Joined: 11 Mar 2010
Posts: 19327

View user's profile Send private message

PostPosted: Thu Feb 17, 2011 8:40 am     Reply with quote

Try changing one line:

setup_spi(SPI_SS_DISABLED);

to

SETUP_SPI(FALSE);

This is a 'balls up' in the Wizard (has been around for a long time), which actually results in the SPI port being _enabled_. Since B1, is the SPI clock output, this might well cause what you are seeing....

Best Wishes
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Thu Feb 17, 2011 10:18 am     Reply with quote

Thanks I will try this tomorrow.....
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 18, 2011 2:23 am     Reply with quote

Yes that did the trick!!!

Thanks Ttelmah!!!!
Jody



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

PostPosted: Fri Feb 18, 2011 4:18 am     Reply with quote

Now I am having a strange problem with B3...
Input toggles but mine code doesn't react on it...

Is this also a fuse problem???
Ttelmah



Joined: 11 Mar 2010
Posts: 19327

View user's profile Send private message

PostPosted: Fri Feb 18, 2011 4:58 am     Reply with quote

Possibly.

Always with this, look at the data sheet, and the pin diagrams. What 'else' may be attached to pin B3?.
Various possible things. VPO, CCP2 and AN9.
Now the last you have potentially already dealt with. NOPBADEN, means that port B wakes up set for digital I/O. So look at the former two. VPO, is the output to drive an external USB transceiver. Not a configuration bit, but a software enabled bit. Clear by default, and only set if you configure the USB driver to use an external transceiver. Shouldn't apply. The last though is affected by a fuse. CCP2C1 or CCP2B3. These set which pin receives the CCP signal. So CCP2C1, might affect your code.
However the default here is for CCP2 to be connected to C1, so this shouldn't apply, and even if the CCP pin was connected here, unless the CCP was enabled, it shouldn't interfere.

Best Wishes
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