View previous topic :: View next topic |
Author |
Message |
Nevillestone
Joined: 05 Aug 2014 Posts: 24
|
Using the 24 bit wizard |
Posted: Tue May 23, 2017 8:38 am |
|
|
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: 19524
|
|
Posted: Tue May 23, 2017 9:24 am |
|
|
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
|
|
Posted: Tue May 23, 2017 1:37 pm |
|
|
Thanks will try _________________ Neville |
|
|
Oreminclutch
Joined: 31 May 2017 Posts: 2
|
|
|
|