I'm trying to configure a development board with STM32F411CEU6.
This board have two crystals (25Mhz and 32,768KHz).
I'm trying to compile code generated from CubeMX with different configurations, but HAL_RCC_OscConfig returns always HAL_TIMEOUT.
I tried to:
stretch the timeout of 1000ms
lower the clock from 100Mhz to 96, 72 and 50MHz.
disable the LSE crystal
but is everything useless.
This is the SystemClock_Config function:
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_RCC_PWR_CLK_ENABLE();
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 200;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 9;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
{
Error_Handler();
}
}
Related
i'm facing an issue in barebox-state. when first stage bootloader runs an error occured
"state: state failed to parse path to backend: No such device"
and in kernel, when i run barebox-state it gives error that
"Neither /aliases/state nor /state found".
i am adding a state node in barebox device tree.
state: state {
#address-cells = <1>;
#size-cells = <1>;
compatible = "barebox,state";
magic = <0xab67421f>;
backend-type = "raw";
backend = <&state_part>;
backend-storage-type = "circular";
bootstate {
system0 {
remaining_attempts#0 {
reg = <0x0 0x4>;
type = "uint32";
default = <3>;
};
priority#4 {
reg = <0x4 0x4>;
type = "uint32";
default = <20>;
};
};
system1 {
remaining_attempts#8 {
reg = <0x8 0x4>;
type = "uint32";
default = <3>;
};
priority#c {
reg = <0xC 0x4>;
type = "uint32";
default = <20>;
};
};
last_chosen#10 {
reg = <0x10 0x4>;
type = "uint32";
};
};
};
and the nand partition looks like this
&gpmc {
/* ... */
nand: nand#0,0 {
/* ... */
state_part: partition#1c0000 {
label = "barebox_state";
reg = <0x1c0000 0x320000>;
};
/* ... */
};
when i add this state for eeprom it works fine. i donot know what is the issue. my barebox version is ""2018.11.0-phy3", dt-utils version is "2021.03.0" and kernel version is "linux-mainline_4.14.78-phy4".
kindly guide me if anyones know. Thanks in advance.
i tried to add the state in eeprom it works fine but in case of nand it creating an issues.
I'm making an app for my drum classes and to make it cross-platform I've chosen Urho.Sharp, because it has low level Sound API as well as rich graphics capabilities.
As a first step I'm making a metronome app and for that I'm working with BufferedSoundStream adding here audio and then needed silence, as described here: https://github.com/xamarin/urho-samples/blob/master/FeatureSamples/Core/29_SoundSynthesis/SoundSynthesis.cs
But the resulting sound is not a sound at all, like random bits got into buffered stream.
This is my code:
///
/// this code initialize sound subsystem
///
void CreateSound()
{
// Sound source needs a node so that it is considered enabled
node = new Node();
SoundSource source = node.CreateComponent<SoundSource>();
soundStream = new BufferedSoundStream();
// Set format: 44100 Hz, sixteen bit, stereo
soundStream.SetFormat(44100, true, true);
// Start playback. We don't have data in the stream yet, but the
SoundSource will wait until there is data,
// as the stream is by default in the "don't stop at end" mode
source.Play(soundStream);
}
///
/// this code preload all sound resources
///
readonly Dictionary<PointSoundType, string> SoundsMapping = new Dictionary<PointSoundType, string>
{
{PointSoundType.beat, "wav/beat.wav"},
{PointSoundType.click, "wav/click.wav"},
{PointSoundType.click_accent, "wav/click_accent.wav"},
{PointSoundType.crash, "wav/crash.wav"},
{PointSoundType.foot_hh, "wav/foot_hh.wav"},
{PointSoundType.hh, "wav/hh.wav"},
{PointSoundType.open_hh, "wav/open_hh.wav"},
{PointSoundType.ride, "wav/ride.wav"},
{PointSoundType.snare, "wav/snare.wav"},
{PointSoundType.tom_1, "wav/tom_1.wav"},
{PointSoundType.tom_2, "wav/tom_2.wav"},
};
Dictionary<PointSoundType, Sound> SoundCache = new Dictionary<PointSoundType, Sound>();
private void LoadSoundResources()
{
// preload all sounds
foreach (var s in SoundsMapping)
{
SoundCache[s.Key] = ResourceCache.GetSound(s.Value);
Debug.WriteLine("resource loaded: " + s.Value + ", length = " + SoundCache[s.Key].Length);
}
}
///
/// this code fill up the stream with audio
///
private void UpdateSound()
{
// Try to keep 1/10 seconds of sound in the buffer, to avoid both dropouts and unnecessary latency
//float targetLength = 1.0f / 10.0f;
// temporary increase buffer to 1s
float targetLength = 1.0f;
float requiredLength = targetLength - soundStream.BufferLength;
if (requiredLength < 0.0f)
return;
uint numSamples = (uint)(soundStream.Frequency * requiredLength);
// check if stream is still full
if (numSamples == 0)
return;
var silencePause = new short[44100];
// iterate and play all sounds
SoundCache.All(s =>
{
soundStream.AddData(s.Value.Handle, s.Value.DataSize);
// add silencio
soundStream.AddData(silencePause, 0, silencePause.Length);
return true;
});
}
Make sure your wav files are in the resource cache. Then don't play the BufferedSoundStream, but the Urho.Audio.Sound sound. This is just a different override of the same method Urho.Audio.SoundSource.Play(), but it works.
int PlaySound(string sSound)
{
var cache = Application.Current.ResourceCache;
Urho.Audio.Sound sound = cache.GetSound(sSound);
if (sound != null)
{
Node soundNode = scene.CreateChild("Sound");
Urho.Audio.SoundSource soundSource = soundNode.CreateComponent<Urho.Audio.SoundSource>();
soundSource.Play(sound);
soundSource.Gain = 0.99f;
return 1;
}
return 0;
}
Since you're using urhosamples, you can start each drum sample from the override update something like this:
public float fRun = 0.0f;
public int iRet = 0; // keep counting the played sounds
public override void OnUpdate(float timeStep)
{
fRun = fRun + timeStep;
int iMS = (int)(10f * fRun); // tenth of seconds
if (iMS == 100) iRet = iRet + PlaySound("wav/hh.wav");
if (iMS == 120) iRet = iRet + PlaySound("wav/hh.wav");
if (iMS == 140) iRet = iRet + PlaySound("wav/hh.wav");
if (iMS == 160) iRet = iRet + PlaySound("wav/open_hh.wav");
if (iMS >= 160) fRun = 0.8f;
}
UPDATE: using the sample from here - http://code.msdn.microsoft.com/wpapps/Location-sample-f11aa4e7 and adding an altitude readout I get the same thing as my code. Poor accuracy is being off by 50ft. Going back and forth between 720 (correct) and 300 ft means something is wrong. I just can't see where...
I'm starting to make a GPS tracking app for windows phone 8 but something is going haywire. In my app, (and in the sample location app) i get some readings that are correct and others that are not. In general, the altitude jumps back and forth between ~95 and ~215 (with 215 being correct). The distance I'm getting is hugely inaccurate as well, quickly jumping to several miles while sitting at my desk or walking around outside.
I'm not sure what code to post, as it is identical to the sample code. If you think there is another relevant section i should post let me know and I'll add it.
double maxSpeed = 0.0;
double maxAlt = -9999999.0;
double minAlt = 9999999.0;
double curDistance = 0.0;
GeoCoordinate lastCoord = null;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if ((bool)IsolatedStorageSettings.ApplicationSettings["LocationConsent"] != true)
{
// The user has opted out of Location.
return;
}
if (App.Geolocator == null)
{
// Use the app's global Geolocator variable
App.Geolocator = new Geolocator();
}
App.Geolocator.DesiredAccuracy = PositionAccuracy.High;
//App.Geolocator.MovementThreshold = 1; // The units are meters.
App.Geolocator.ReportInterval = 1000;
//App.Geolocator.DesiredAccuracyInMeters = 50;
App.Geolocator.StatusChanged += geolocator_StatusChanged;
App.Geolocator.PositionChanged += geolocator_PositionChanged;
/*
geolocator = new Geolocator();
geolocator.DesiredAccuracy = PositionAccuracy.High;
//geolocator.MovementThreshold = 1; // The units are meters.
geolocator.ReportInterval = 1000;
geolocator.StatusChanged += geolocator_StatusChanged;
geolocator.PositionChanged += geolocator_PositionChanged;
*
* */
logging = true;
startTime = DateTime.Now;
}
public static GeoCoordinate ConvertGeocoordinate(Geocoordinate geocoordinate)
{
return new GeoCoordinate
(
geocoordinate.Latitude,
geocoordinate.Longitude,
geocoordinate.Altitude ?? Double.NaN,
geocoordinate.Accuracy,
geocoordinate.AltitudeAccuracy ?? Double.NaN,
geocoordinate.Speed ?? Double.NaN,
geocoordinate.Heading ?? Double.NaN
);
}
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
Dispatcher.BeginInvoke(() =>
{
if (lastCoord == null)
{
lastCoord = ConvertGeocoordinate(args.Position.Coordinate);
}
DateTime currentTime = DateTime.Now;
TimeSpan totalTime = currentTime - startTime;
timeValue.Text = totalTime.ToString(#"hh\:mm\:ss");
System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Altitude.ToString());
GeoCoordinate thisLocation = ConvertGeocoordinate(args.Position.Coordinate);
if (true) //units check true = standard
{
double speed = (double)thisLocation.Speed;
speed *= 2.23694; //m/s -> mph
speedValue.Text = speed.ToString("0");
double alt = (double)thisLocation.Altitude;
if (alt > maxAlt)
{
maxAlt = alt;
}
if (alt < minAlt)
{
minAlt = alt;
}
/*
double currentAlt = (maxAlt - minAlt);
currentAlt *= 3.28084; //m -> ft
* */
alt *= 3.28084;
altValue.Text = alt.ToString("0");
double distance = thisLocation.GetDistanceTo(lastCoord);
curDistance += distance;
distance = curDistance * 0.000621371; // m -> miles
distanceValue.Text = distance.ToString("0.00");
distanceUnits.Text = "(mi)";
speedUnits.Text = "(mph)";
altUnits.Text = "(ft)";
}
});
}
EDIT: I didn't mention, but the speed is perfectly fine as an fyi. the lat / long is pretty close in general to where i am as well, so I don't think it's a hardware issue.
UPDATE: When stopping in the debugger to check the value instead of just printing it, it gives this:
Altitude = An internal error has occurred while evaluating method Windows.Devices.Geolocation.Geocoordinate.get_Altitude()
I tried to search for this, but the error is nowhere to be found on the internet...
The documentation states that altitude and a few others aren't guaranteed, but it also says that the value will be null if it isn't there. I check, and it's never null. It always prints a value, either correct or ~400 ft off.
UPDATE: Sample code:
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
System.Diagnostics.Debug.WriteLine(args.Position.Coordinate.Altitude.ToString());
if (!App.RunningInBackground)
{
Dispatcher.BeginInvoke(() =>
{
LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString("0.00");
LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString("0.00");
});
}
else
{
Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
toast.Content = args.Position.Coordinate.Latitude.ToString("0.00");
toast.Title = "Location: ";
toast.NavigationUri = new Uri("/MainPage.xaml", UriKind.Relative);
toast.Show();
}
}
You might be seeing a different issues (too) but GPS altitudes are not very reliable. I have a few Garmin devices and they all jump about all over the place. You really need a barometer for decent altitude accuracy.
Here is a link on GPS attitude inaccuracy GPS Elevation
I am able to inject pointer/touch messages successfully but unable to receive all the messages injected on an application (messages are captured in the application) even though all the messages are injected successfully without any errors. Please do provide any suggestions/solution for the issue.
InitializeTouchInjection(10, TOUCH_FEEDBACK_INDIRECT);
//
// initialize the touch info structure
//
memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
contact.pointerInfo.pointerType = PT_TOUCH; //we're sending touch input
contact.pointerInfo.pointerId = 0; //contact 0
contact.pointerInfo.ptPixelLocation.x = 300;
contact.pointerInfo.ptPixelLocation.y = 300;
contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
contact.touchFlags = TOUCH_FLAG_NONE;
contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
contact.orientation = 90;
contact.pressure = 32000;
//
// set the contact area depending on thickness
//
// defining contact area (I have taken area of 4 x 4 pixel)
contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x - 2;
contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x + 2;
//
// inject a touch down
//
bRet = InjectTouchInput(1, &contact);
//Setting the Pointer Flag to Drag
contact.pointerInfo.pointerFlags = POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
bRet = InjectTouchInput(1, &contact);
for(int i=0;i<100;i++)
{
contact.pointerInfo.ptPixelLocation.y--;
bRet =InjectTouchInput(1, &contact);
}
//
// if touch down was succesfull, send a touch up
//
if (bRet) {
contact.pointerInfo.pointerFlags = POINTER_FLAG_UP;
//
// inject a touch up
//
InjectTouchInput(1, &contact);
}
I need a routine to randomly select records from ADAM (Active Directory Application Mode). Any advice to get me started on this task?
Use a DirectorySearcher filter with (objectClass=user) and pick a result at random might work. Something like ...
private static Random rnd = new Random();
private static DirectoryEntry GetRandomUser()
{
DirectoryEntry luckyGuy;
var de = new DirectoryEntry(/*conn string*/);
de.Username = /* your user */;
de.Password = /* your pass */;
// error handling and try-catch removed for clarity and brevity
var s = new DirectorySearcher( de );
s.Filter = "(objectClass=user)";
var res = s.FindAll();
if( res.Count > 0 )
{
var idex = rnd.Next(0, res.Count);
luckyGuy = res[idex].GetDirectoryEntry();
}
return luckyGuy;
}
Here's more on DirectorySearcher.