 |
 |
View previous topic :: View next topic |
Author |
Message |
JerryR
Joined: 07 Feb 2008 Posts: 176
|
CCS SMT example builds but does verify |
Posted: Tue Sep 09, 2025 8:17 am |
|
|
Hello Group:
I have been experimenting with the SMT peripheral and started with the CCS example "ex_smt_period_duty.c". The only edit I made to this example is I'm using a PIC16F1619 instead of a PIC16F1618, so I used the appropriate include file.
I'm using CCS PCWH 5.120 to build. CCS ICD-U80 as debugger/programmer. Target is my design and programs, verifies, and runs with any other code.
The code builds correctly, but does not verify unless I comment out the two SMT-related interrupts.
CCSLoad reports correct voltage, and matched PIC devices. I have tried erasing manually with CCSLoad, same results, no verify.
Here's the code:
Code: |
#include <16F1619.h> //Changed from 16F1618
#define SMT_INPUT PIN_C1
#use delay(internal=8MHz)
#pin_select U1TX=PIN_C6
#pin_select U1RX=PIN_C7
//#use rs232(icd, baud=9600) //Text though the ICD
#use rs232(UART1, baud=9600) //Text through the UART
#pin_select SMT1SIG=SMT_INPUT
unsigned int32 SignalDuty;
unsigned int32 SignalPeriod;
int1 NewCapture = FALSE;
/* Programs and verifies when commented out
#INT_SMT1PRA
void period_isr(void)
{
SignalPeriod = smt1_read(SMT_CAPTURED_PERIOD_REG); //read captured period
NewCapture = TRUE;
}
#INT_SMT1PWA
void duty_isr(void)
{
SignalDuty = smt1_read(SMT_CAPTURED_PULSE_WIDTH_REG); //read captured duty
}
*/
char* CalculatePeriod(void)
{
static char str[10];
float period;
int8 t = 0;
int8 Count;
period = (float)SignalPeriod * (1.0 / (float)getenv("CLOCK"));
while(period < 1)
{
period *= 1000.0;
t++;
}
Count = sprintf(str, "%0.2f ", period);
switch(t)
{
case 0:
sprintf(&str[Count], "s");
break;
case 1:
sprintf(&str[Count], "ms");
break;
case 2:
sprintf(&str[Count], "us");
break;
default:
sprintf(&str[Count], "ns");
break;
}
return(str);
}
float CalculateDuty(void)
{
float duty;
duty = ((float)SignalDuty * 100.0) / (float)SignalPeriod;
return(duty);
}
void main(void)
{
printf("\r\nex_smt_period_duty.c - %s\r\n\n", getenv("DEVICE"));
//setup SMT1 for Period and Duty Cycle Acquisition Mode, Input signal on SMT1SIG pin
setup_smt1(SMT_ENABLED | SMT_MODE_PERIOD_DUTY_CYCLE_ACQ | SMT_CLK_FOSC | SMT_SIG_INPUT_SMTSIGx);
enable_interrupts(INT_SMT1PRA); //enable SMT1PRA interrupt to capture period
enable_interrupts(INT_SMT1PWA); //enable SMT1PWA interrupt to capture duty
enable_interrupts(GLOBAL);
smt1_start(); //start SMT1
while(TRUE)
{
if(NewCapture)
{
printf("\r\nSignal Period: %s, Duty: %0.2f%%", CalculatePeriod(), CalculateDuty());
NewCapture = FALSE;
smt1_start(); //re-start SMT1
}
}
}
|
Any thoughts are much appreciated!! |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9575 Location: Greensville,Ontario
|
|
Posted: Wed Sep 10, 2025 5:28 am |
|
|
While I don't use them ,I am curious... so I had a quik look at the 1618 and 1619... both have SMT and seem 'similar'....
Does the code verify with the 1618 PIC ?
Maybe look at the headers, compare and see if there's something 'different' about the 'SMT' sections ? I'd think they should be 100% the same ? |
|
 |
JerryR
Joined: 07 Feb 2008 Posts: 176
|
|
Posted: Wed Sep 10, 2025 6:02 am |
|
|
Thanks for considering my post Temtronic!
I don't have a 1618 target to test verification, that would be a great experiment, however.
I do know if I just comment out the interrupts associated with the SMT, it builds and verifies. In all cases the code builds. When verification takes place, after programing, there is code there, just not what's expected.
Must have something to do with where the build places the interrupts. That's a great suggestion to check the device's header against the 1618.
Again, I appreciate your help! |
|
 |
JerryR
Joined: 07 Feb 2008 Posts: 176
|
|
Posted: Wed Sep 10, 2025 6:03 am |
|
|
Thanks for considering my post Temtronic!
I don't have a 1618 target to test verification, that would be a great experiment, however.
I do know if I just comment out the interrupts associated with the SMT, it builds and verifies. In all cases the code builds. When verification takes place, after programing, there is code there, just not what's expected.
Must have something to do with where the build places the interrupts. That's a great suggestion to check the device's header against the 1618.
Again, I appreciate your help! |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19939
|
|
Posted: Wed Sep 10, 2025 11:04 am |
|
|
Could you try going back to some older firmware on the ICD?.
There have been a number of issues with the latest updates to some of
the CCS ICD units not programming some chips/features correctly.
In the device editor, it might be worth trying changing the programming
method option. There are a lot of different options, and the more basic
options sometime work, but are slow, while the faster options are the ones
that are having problems.
It really does sound like a programming issue affecting some specific
part of the program memory, or some specific instruction.
It may only be a read problem. Does the code work if you disable verify?.
Have you tried with other interrupts enabled/present?. You might just
have a chip with a memory fault in the area used when the interrupts
are present.
I would suggest you talk to CCS about this. They seem to have been
tweaking the programming algorithms recently, and they are faster, but
seem to be giving a lot of issues. |
|
 |
JerryR
Joined: 07 Feb 2008 Posts: 176
|
|
Posted: Wed Sep 10, 2025 11:59 am |
|
|
Hi Ttelmah:
Thanks for your interest!
Well, I do know that the code mismatches as far down as I can see after programming and I can get other code working well on the same target. Also, code does run if I compile and program with the two interrupts commented out.
I only have one ICD-U80, but it does seem to program other targets using different processors well. I do have several Microchip debuggers and programmers, but have really never been able to get CCS IDE to work with them.
To your suggestion, I'll try programming the troublesome target using Microchip Studio or an old version of MPLAB 8x before involving CCS. If I can successfully program with Microchip tools, I'll speak with CCS.
Thanks again my friend |
|
 |
|
|
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
|