Page 1 of 1

Stray \xxx in program

Posted: Thu Jun 06, 2013 2:56 pm
by xt5160
I'm trying to use PWM on the MOD5213. I cut/pasted the example code from the App Note, but NBEclipse won't save the file; I get an "error: stray '\315' in program" (and other codes). There are numerous instances.
A search for the offending code yields "not found". There does not appear to be a way to use regular expressions; I've tried \x13B and it fails, too.

Does anybody have any suggestions (other than retype the example)?

Re: Stray \xxx in program

Posted: Thu Jun 06, 2013 6:56 pm
by Ridgeglider
My guess is that you have cut, then pasted some artifact out of the pdf example code. In my experience, problem areas to look out for occur around page breaks, page numbers, etc. I saved the pdf as a plain text file to eliminate some of these artifacts. Maybe this would work? It's been a while since i used 5213.


/*********************************************************************/ 
/* This example program exercises the pulse width modulation */ 
/* module in the MCF5213 CPU.  When running this program on the  */ 
/* MOD5213, there should be an output frequency of about 829.4 kHz */ 
/* on pin 24 (use of an oscilloscope to measure this is */
/* recommended). To achieve this value through calculation, */
/* consider the following case: */
/* */ 
/* The CPU frequency of the MCF5213 is 66.3552 Mhz. The internal */ 
/* bus clock is determined by dividing this value by 2. Therefore, */ 
/* the internal bus clock is 33.1776 Mhz. Channel 0 is programmed  */ 
/* to use clock SA, so the internal bus clock passes through a */
/* divisor prescaler of clock A, and then through an additional  */ 
/* divisor prescaler of clock SA, which is then again further  */ 
/* divided by 2. After dividing the resulting frequency by the */ 
/* value present in the channel period register (5), you get the */ 
/* output frequency on pin 24. */ 
/* */ 
/* The duty cycle value in the channel duty register is 3. When  */ 
/* the PWM counter matches the duty register, the output flip­flop */
/* changes state causing the PWM waveform to also change state.  */ 
/* The duty cycle with the current configuration is: */ 
/* */
/* Duty Cycle = (1 ­ PWMPOL[PPOLn] ­ (PWMDTYn/PWMPERn)) x 100% */ 
/* = (1 ­0 ­( 3 / 5 )) x 100% */
/* = 40%  */ 
/*********************************************************************/ 

#include "predef.h" 
#include <stdio.h>
#include <ctype.h>
#include <basictypes.h> 
#include <serialirq.h>
#include <system.h> 
#include <constants.h>
#include <ucos.h> 
#include <serialupdate.h> 
#include <pins.h> 
#include <..\MOD5213\system\sim5213.h>

//
// Instruct the C++ compiler not to mangle the function name
//

extern "C"   {

void  UserMain( void *pd ); 
}
 

//
// Name for development tools to identify this application
//

const char *AppName = "Mod5213PWMDemo";
 

/////////////////////////////////////////////////////////////////////// 
// UserMain ­Main task.

//

void  UserMain( void *pd )  {
OSChangePrio( MAIN_PRIO );
EnableSerialUpdate(); 

SimpleUart( 0, SystemBaud ); 

assign_stdio( 0 );

////////////////////////////////////////////////////////////////////
// Configure pin 24 for PWM Channel 0 functionality 

// Set for PWM functionality

Pins[24].function( PIN24_PWM0 ); 

// Disable all PWM channel output before making any settings

sim.pwm.pwme = 0; 

// Set to have an initial low signal, then set high on duty output
// compare

sim.pwm.pwmpol &= ~0x01; 

// Set to use clock SA (Scale A)

sim.pwm.pwmclk |= 0x01; 

// Set to use a clock A prescale value of 2 (Internal Bus Clock /
// 2^1) 

sim.pwm.pwmprclk |= 0x01; 

// Set to operate channel 0 in left­aligned output mode 

sim.pwm.pwmcae &= ~0x01; 

// All channels are independent 8­bit channels; doze and debug mode 
// disabled 

sim.pwm.pwmctl = 0; 

// Use scale divisor value of 2 to generate clock SA from clock A 

sim.pwm.pwmscla = 0x02; 

// Write any value to this register to reset the counter and start
// off clean

sim.pwm.pwmcnt[0] = 1; 

// Set PWM Channel 0 period register to a value of 5

sim.pwm.pwmper[0] = 5; 

// Set PWM Channel 0 duty register to a value of 3

sim.pwm.pwmdty[0] = 3; 

// Enable PWM output for PWM Channel 0

sim.pwm.pwme |= 0x01; 

iprintf( "Application started\r\n" );

while ( 1 )  { 
OSTimeDly( TICKS_PER_SECOND );
}
}

Re: Stray \xxx in program

Posted: Fri Jun 07, 2013 8:44 am
by xt5160
Thanks for the effort, but cut/paste from your reply has exactly the same errors. Having said that, I was able to determine the offending characters, by individually replacing each character in the line containing the error and attempting a save/build. In my particular case, it turned out to be the semicolon character (the cut from the PDF was a Unicode semicolon, 0000 037E). Once determined, I could search/replace the rest. I'm just annoyed that the error displayed was not searchable.

Still have some compile issue that are strange.... UserMain defined twice and AppName generates error.

Re: Stray \xxx in program

Posted: Fri Jun 07, 2013 11:52 am
by tod
I would suspect the leading slash is "escaping" the following digits and resulting in an unprintable character. I know I had a similar problem once. Wouldn't compile but couldn't find the offending data. As I recall I was able to open the offending files with an external editor that showed glyphs for them and easily delete them.