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

Using the 24 bit wizard

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



Joined: 05 Aug 2014
Posts: 24

View user's profile Send private message

Using the 24 bit wizard
PostPosted: Tue May 23, 2017 8:38 am     Reply with quote

Hi
Compiler Version PCD 5.071d
Chip 24EP256MC204

I've used the 24 bit wizard to generate the following code to get the PWM on this device working.
There is no output on B14 or B15.
I've distilled it down to bare bones and still nothing all the code is generated by the wizard other than the RL1 toggling that is happening.
Can anybody offer any advice on what could be wrong?


Header file:
Code:

#include <24EP256MC204.h>
#device ICSP=3
#device ADC=12
#use delay(crystal=20000000)

#FUSES WDT                      //Watch Dog Timer
#FUSES WPRES32                  //Watch Dog Timer PreScalar 1:32
#FUSES WPOSTS1                  //Watch Dog Timer PostScalar 1:1
#FUSES NOJTAG                   //JTAG disabled
#FUSES CKSFSM                   //Clock Switching is enabled, fail Safe clock monitor is enabled


#use pwm(OC1,OUTPUT=PIN_B14,TIMER=2,FREQUENCY=150,DUTY=50)
#define RL1   PIN_C6


Main file:
Code:

#include <PWMTST.h>

int1 test;

void main()
{


   setup_adc_ports(sAN0 | sAN1 | sAN2 | sAN3 | sAN4 | sAN5 | sAN6 | sAN7, VSS_VDD);
   setup_adc(ADC_CLOCK | ADC_TAD_MUL_2);

   while(TRUE)
   {
   Delay_ms(1000);
   test=input_state(RL1);
    output_bit(RL1,!test);   //TODO: User Code
   }

}

_________________
Neville
Ttelmah



Joined: 11 Mar 2010
Posts: 19545

View user's profile Send private message

PostPosted: Tue May 23, 2017 9:24 am     Reply with quote

The wizard is worse than useless.....

Understand that it'll try to do what you tell it. Unfortunately, unless you tell it the right things, the results won't work. Since this implies you need to know what to tell it, you are much better off setting things up yourself.

Straight away, your ADC clock value is too fast (for 12bit mode Tad min is 117.6nSec, but you have 100nSec selected). A classic example of a 'wizard error'....

Now on the PWM, there are a couple of settings for the PWM, that #use doesn't give you access to. I'd suspect one of these is resulting in the PWM not running.
For instance, the default OC PWM setting has the fault input enabled, which will lock the output 'low'....

Look at the ex_pwm_pcd.c and setup the PWM yourself.
Nevillestone



Joined: 05 Aug 2014
Posts: 24

View user's profile Send private message

PostPosted: Tue May 23, 2017 1:37 pm     Reply with quote

Thanks will try Crying or Very sad
_________________
Neville
Oreminclutch



Joined: 31 May 2017
Posts: 2

View user's profile Send private message

PostPosted: Wed May 31, 2017 6:54 am     Reply with quote

Going to go ahead and second the fact that the wizard is useless.

top 3 best roulette chat sites
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