- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello you all! http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
I've just begun playing with Nios Development Kit - Cyclone Edition. I'm using the count binary tutorial to do my tests. Now I would like to generate a square wave on a pin on J11; let's say pin 39, connected to pin PIN_J16 of the 1c20. I think I've to do the following steps: 1. in sopc builder, I've to add a new PIO module. 2. in the bdf, I bind the pio output to pin j16 3. in the software, I've to write something to set and reset the pin. Are these steps correct? And about step 3, how do I set and reset the pin in C? Thanks in advance! My regards, Marco LazzaroniLink Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think it's simpler to generate a square wave in hardware using only the second step you've written (and eventually adding a clock divider/multiplier)...
I think it's more correct too, because a sqare wave generated by software it's not reliable... (and it's the first time I've heard it) http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/wink.gif Bye!- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
> Are these steps correct?
yes :-) > And about step 3, how do I set and reset the pin in C? Just define a pointer to the 'data' register and write the data you want. If your're using data cache, you may want to set bit 31 of the address. unsigned long *p = (unsigned long *) 0xSOMEADDR; ... for (;;) {*p = 1; *p = 0;} --Scott- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you both for your useful replies http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/smile.gif
I think I'll follow Scott's advice since at the moment I'm focused on getting direct access to pins. Thank you again :-)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
To generate a square wave, you can use a counter with a compare tacked on. Adjust the compare value to change the duty cycle, and change the value that gets loaded into the counter to adjust the frequency (so you have 2 registers sitting outside of the NIOS to control the wave generation, and around 20-40 LEs of hardware for the wave generation). You will have to figure out duty cycles based on the frequency since you are loading clock cycles and not Hz into this thing, but that'll just be simple math (multiply and divide).
I have seen software based generation, however you will not be clock cycle accurate if you take that route so I would splurge and use up logic to make one in hardware (you can make it accurate to within one clock cycle). Cheers.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page