- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to get som random numbers from the PRS hardware.
But I get the same number every time.
How du I get different numbers ?
Ran1=PRS_Read();
Ran2=PRS_Read();
Ran3=PRS_Read();
Ran4=PRS_Read();
Ran5=PRS_Read()*256;
There is no PRS_Step() finction in Psoc_creator 4.4 as I can see.
Regards Erik
Solved! Go to Solution.
- Labels:
-
PSOC5 LP MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Erik,
The PSoC GCC compiler also supports the ANSI rand() function. This doesn't require any UDB resources like the PRS does.
I added the rand() call into moto-san's project.
Basic changes:
- Added #include "stdlib.h"
- Added the rand() to the snprintf() call.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Wow, I did not know that there is a component "PRS"!
Thank you for your asking 😉
It seems that most likely you forgot to call PRS_Start() before using PRS_Read().
I tested with CY8CKIT-059.
schematic
Pins
main.c
#include "project.h"
#include "stdio.h"
#define STR_BUF_LEN 64
char str[STR_BUF_LEN+1] ;
void print(char *str)
{
UART_PutString(str) ;
}
int main(void)
{
uint8_t prs_value = 0 ;
CyGlobalIntEnable; /* Enable global interrupts. */
UART_Start() ;
print("\x1b[2J\x1b[;H") ;
print("PSoC 5LP PRS Test ") ;
snprintf(str, STR_BUF_LEN, "(%s %s)\n\r", __DATE__, __TIME__) ;
print(str) ;
PRS_Start() ;
for(;;)
{
prs_value = PRS_Read() ;
snprintf(str, STR_BUF_LEN, "%02X\n\r", prs_value) ;
print(str) ;
CyDelay(500) ;
}
}
Tera Term log (uart output)
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Erik,
The PSoC GCC compiler also supports the ANSI rand() function. This doesn't require any UDB resources like the PRS does.
I added the rand() call into moto-san's project.
Basic changes:
- Added #include "stdlib.h"
- Added the rand() to the snprintf() call.
"Engineering is an Art. The Art of Compromise."
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the answers both solution works for me now.