Pass port as a parameter in bascom-avr - bascom

Can this be done? pass a port as a parameter?
I have 4 stepper motors that I want to command but I don't want to create separated cod for each stepper

Related

How can I use a serial port to listen to if toggles are switched?

In my software I need to detect when an operator toggles one of two miniature toggle electric switches:
and which one.
I want to do this with as little external hardware as possible.
I was thinking that maybe I could use a USB to serial cable?
Looking at the WaitCommEvent documentation I notice that I can listen to for instance:
EV_CTS: The CTS (clear-to-send) signal changed state.
EV_DSR: The DSR
(data-set-ready) signal changed state.
Looking at the DB-9 pins:
It seems that I could connect a voltage source trough the toggle 1 to pin 8 (CTS) and to ground?
Likewise it seems that I could connect a voltage source trough the toggle 2 to pin 6 (DSR) and to ground?
Will this work? Is there a better way to do this only using a USB to serial cable?
For the sake of sparing you the work of reposting to the electronics exchange:
According to this document, setting CTS on means a voltage of at least +3V on the CTS line, relative to GND. Similarly, setting CTS off means a voltage of at least -3V on the CTS line, relative to GND. So you'd need two voltage sources, one for >+3V (GND to Serial GND) and one isolated one for <-3V (Plus to Serial GND).
DSR functions similarly, according to the document.
Also, your switch looks like an SPST. You'd need at least an SPDT for this if you want to avoid using resistors.

Easy way to increment a demux without calling each pin every time?

I need to increment through 2 demultiplexers. Right this moment I have it set up to where every time it just enables those specific pins as the output. I have been trying to wrap my head around an easy way to increment this in a function and or being able to call specific outputs? Or would the only way really would be to have a function called void trigger(int output) and have a switch statement within it for each of the 16 outputs and their associated pin triggers.
Increment the outputs through the various inputs. They are currently being used to drive a set of LEDs.
transformer(dv_out, 0); //recharge transformer
module_0_SetHigh();
module_1_SetHigh();
if (!sec) {
demux0_SetHigh();
demux0_SetLow();
}
if (sec) {
demux1_SetHigh();
demux1_SetLow();
}
module_0_SetLow(); //disable pin select
module_1_SetLow();

UVM TB and DUT parameter control

Please help to resolve one issue that I am facing with planning my TB.
Let’s assume my DUT has some input port which is parameter, something like:
module Multiplier #(parameter WIDTH = 8) (
input [WIDTH-1:0] addr,
Now I want my test to control this WIDTH parameter.
I want the test to randomize the WIDTH parameter, then apply that parameter to DUT. And based on that parameter value my whole testbench will be changed the transaction signals, driver, monitor and so on.
What is the best way to implement this parametric test?
I am thinking to have the WIDTH parameter in test class, and randomize it there. Then assign it to the DUT during instantiation. And for TB, put the randomize value in config_db and in agent get it and assign it to config class appropriate parameter.
Thanks
Hayk
I would generate a random variable in my Makefile (or whatever build/compilation system you are using). Then depending on your simulator, set the parameter from the simulation run command.
ModelSim:
The Parameters value can be passed with ‘vsim’ command in the ModelSim simulator. Assuming we want to supply a parameter value globally to all the modules:
-gWIDTH=<random_value>
VCS
-pvalue+hierarchical_name_of_parameter=<random_value>
All simulators have an equivalent.

How to connect two STM32F4-Discovery cards with LCDs through USART

I am currently doing a project in school where me and my group are supposed to make the game "Bomberman" and execute it on a STM32F4-Discovery card (which has an ARM based processor on it). The game is displayed on a small LCD touchscreen that is connected to the discovery card, the touchscreen is also used as the controller for the game. The game is playable as of now, everything executes correctly and you can play alone against three AI-characters. The game and all hardware initiations are written entirely in C.
Now we have decided we want to implement multiplayer in the game, meaning we will have two setups of STM32F4-Discovery cards and LCD touchscreens. Each setup controls one player on the same game map. We are supposed to connect the two setups through USART.
My question is, how do we make these two STM32F4-Discovery cards communicate and display the same game map? I've tried to google it without any success so I now turn to you at stackoverflow.
EDIT: I am adding a follow up question in the light of the information provided by Unwind.
Follow up question:
We got a lot of pre-written files that we could use to initiate our hardware etc. One of these files are called STM32F4xx-usart.c. It contains a function:
void USART_Init(USART_TypeDef* USARTx, USART_InitTypeDef* USART_InitStruct).
The USART_InitStruct looks like this (it was pre-defined in the code that we got):
typedef struct{
uint32_t USART_BaudRate;
uint16_t USART_WordLength;
uint16_t USART_StopBits;
uint16_t USART_Parity;
uint16_t USART_Mode;
uint16_t USART_HardwareFlowControl;
} USART_InitTypeDef;
I am guessing I will have to use this structure to form two new structs that will hold the values for my master card and my slave card.
My question is: How do I write these two structs so that I can pass it to the init_USART() function?
You don't need to provide any values, only the syntax.
I tried
struct USART1_initStruct{
uint32_t USART_BaudRate;
uint16_t USART_WordLength;
uint16_t USART_StopBits;
uint16_t USART_Parity ;
uint16_t USART_Mode ;
uint16_t USART_HardwareFlowControl;
} U1IS = {9600, USART_WordLength_9b, USART_StopBits_1, USART_Parity_No, USART_Mode_Tx, USART_HardwareFlowControl_None};
and then passing this struct to the function, but I got an error:
error: expected expression before 'struct'
Make one of the boards the master, and the other the slave.
The job of the master (or server) is to run the game and decide what happens. The role of the slave (or client) is to display the world view to its local player, send input to the master and receive updates on the game's objects.
You can also view it as two slaves, connected to a single master which also happens to run on the same physical machine as one of the slaves.
It's not going to be very simple, especially since it sounds as if you didn't design for this from the beginning which usually helps.
USART_InitTypeDef x;
x.BaudRate = 9600;
x.WordLength = USART_WordLength_9b;
... etc
USART_Init(USART1,&x);
Look at any of the example code provided by STM.

singlelineedit & datawindow/datastore - Sybase

I want to use singlelineedit as input.
So I've 4 input fields and a button.
I want to pass the inputs to datawindow/datastore when i click the button.
How do I write the code in the clicked event of the button?
I've created a datawindow namely dw_insert_into_table1 which built on top of a store procedure which is expecting 4 arguments.
Thank you.
long rows
rows = dw_insert_into_table1.retrieve( sle_input_1.text, &
sle_input_2.text, sle_input_3.text, sle_input_4.text )
Note that dw_insert_into_table1 must have been connected to a transaction object
with setTransobject or setTrans method before a call to the retrieve method, and be sure to pass input field value in the right order, the one you have defined your retrival arguments in the datawindow definition.

Resources