- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to use the CyBle_GenerateRandomNumber() function and it always returns the same values. This is typical of a random generator function but usually there is a function to provide a seed but I cannot find any such function. How does this function get its seed? I can live with the device producing the same list of random numbers but I need to know that each separate device will be different.
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why not using the rand() library function? You can initialize it via srand(), using the current value of the SysTick timer (see http://www.cypress.com/knowledge-base-article/using-systick-timer-psoc-4-kba91374 ). Call srand when your BLE pairing happens since this is a random point in time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why not using the rand() library function? You can initialize it via srand(), using the current value of the SysTick timer (see http://www.cypress.com/knowledge-base-article/using-systick-timer-psoc-4-kba91374 ). Call srand when your BLE pairing happens since this is a random point in time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I cannot wait until BLE pairing because I need the random value immediately on first boot which happens at our manufacturing facility on a test stand. In this environment, I am not sure how good the SysTick method would work since the timing would be very much the same from unit to unit. I have also investigated using die temperature, ADC counts of battery, etc. but again during test all of these are likely to be the same. Essentially on boot I will check a SFLASH location for this ID value and if it has not been set then I will generate the random number and write it to SFLASH. I was hoping someone from Cypress would chime in with some information about how that function works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was hoping someone from Cypress would chime in
At top of this page select "Design Support -> Create a Support Case" and describe your problem.
Alternate solution: There is an API to get the unique chip ID. Use that directly or use it to seed the randomizer.
See "System Reference Guide" (from Creator Help)
void CyGetUniqueID(uint32* uniqueId)
Description:
Returns the 64-bit unique id of the device
Parameters:
uniqueId: Pointer to a two element 32-bit unsigned integer array.
Return Value:
Returns the 64-bit unique id of the device by loading them into the integer array pointed to by uniqueId
Bob