EM2019WSP12/Feindesign: Unterschied zwischen den Versionen
Aus Verteilte Systeme - Wiki
(→ADC Feindesign) |
(→Counter Feindesign) |
||
Zeile 48: | Zeile 48: | ||
// Initialize a PPI channel | // Initialize a PPI channel | ||
void ppi_init(void){ | void ppi_init(void){ | ||
− | + | nrfx_err_t errvalue; | |
− | + | /*get a ppi channel for CCD CLK to count the pixel*/ | |
− | + | memset(&count_channel_pixel, 0, sizeof(nrf_ppi_channel_t)); | |
− | + | errvalue = nrfx_ppi_channel_alloc(&count_channel_pixel); | |
− | + | if(errvalue == NRFX_SUCCESS){ | |
− | + | printk("nrfx_ppi_channel_alloc returned Success!\n"); | |
− | + | } | |
− | + | if(errvalue == NRFX_ERROR_NO_MEM){ | |
− | + | printk("nrfx_ppi_channel_alloc returned Error No Mem!\n"); | |
− | + | } | |
− | + | ||
− | + | /* | |
− | + | Event End Points are used as a trigger. | |
− | + | */ | |
− | + | /*Get CCD_CLK = EXT_A0_GPIO_PIN (EET - Event End Point) adress*/ | |
− | + | uint32_t gpiote_event_pixel = nrfx_gpiote_in_event_addr_get(CCD_CLK); | |
− | + | ||
− | + | /* | |
− | + | Task End Points are getting triggered by Event End Points | |
− | + | Get Counter (TEP - Task End Point) adress | |
− | + | */ | |
− | + | /*nrfx_timer_task_address_get - Function for returning the address of a specific timer task. | |
− | + | Parameters | |
− | + | [in] p_instance Pointer to the driver instance structure. | |
− | + | [in] timer_task Timer task. | |
− | + | Returns - Task address. | |
− | + | (NRF_TIMER_TASK_COUNT = Task for incrementing the timer (in counter mode)) | |
+ | */ | ||
+ | uint32_t counter_addr_pixel = nrfx_timer_task_address_get(&counter_pixel, NRF_TIMER_TASK_COUNT); |
Version vom 4. März 2020, 23:35 Uhr
Inhaltsverzeichnis
Feindesign
Im folgenden ist der derzeitig Programmablauf dargestellt.
Da dieser Programmablauf zu Interrupt Überlagerungen kommen kann wird
das Programm noch so abgeändert, dass der StartOfIntegration Pin über polling abgefragt wird.
ADC Feindesign
Da keine hohe Auflösung des Analog/Digital-Konverters notwendig ist, werden alle Parameter so eingestellt, dass der ADC möglichst schnell seine Werte liefern kann.
/* ADC struct (definitions can be found in adc.h) */ static const struct adc_channel_cfg m_2nd_channel_cfg = { .gain = ADC_GAIN, //5 is gain of 1x .reference = ADC_REFERENCE, // default ref. is GND .acquisition_time = ADC_ACQUISITION_TIME, //1 = 5µs, ADC_ACQUISITION_TIME .channel_id = ADC_2ND_CHANNEL_INPUT, .input_positive = ADC_2ND_CHANNEL_INPUT, }; struct device *get_adc_device(void){ return device_get_binding(ADC_DEVICE_NAME); } const struct adc_sequence sequence = { .channels = BIT(ADC_2ND_CHANNEL_INPUT), .buffer = adc_buffer, .buffer_size = sizeof(adc_buffer), .resolution = 8, //8,10,12 ADC_RESOLUTION .oversampling = 0, //0, 4 };
MIDI Feindesign
Da MIDI 31250 Baud statt 115200 Baud (bei UART) verwendet wird diese Baudrate bei Programmbeginn eingestellt.
initUART0(); uart_cfg.baudrate = 31250; //115200 default, 31250 MIDI uart_cfg.parity = UART_CFG_PARITY_NONE; uart_cfg.stop_bits = UART_CFG_STOP_BITS_1; uart_cfg.flow_ctrl = UART_CFG_FLOW_CTRL_NONE; uart_cfg.data_bits = UART_CFG_DATA_BITS_8; uart_configure(UART0_dev, &uart_cfg); // Take new settings
Counter Feindesign
Um nebenläufig die Clock des Evaluationsboards mitlesen zu können wurde ein Counter über ein PPI (Programmable Peripheral Interconnect) mit einem GPIO Pin verbunden.
// Initialize a PPI channel void ppi_init(void){ nrfx_err_t errvalue; /*get a ppi channel for CCD CLK to count the pixel*/ memset(&count_channel_pixel, 0, sizeof(nrf_ppi_channel_t)); errvalue = nrfx_ppi_channel_alloc(&count_channel_pixel); if(errvalue == NRFX_SUCCESS){ printk("nrfx_ppi_channel_alloc returned Success!\n"); } if(errvalue == NRFX_ERROR_NO_MEM){ printk("nrfx_ppi_channel_alloc returned Error No Mem!\n"); } /* Event End Points are used as a trigger. */ /*Get CCD_CLK = EXT_A0_GPIO_PIN (EET - Event End Point) adress*/ uint32_t gpiote_event_pixel = nrfx_gpiote_in_event_addr_get(CCD_CLK); /* Task End Points are getting triggered by Event End Points Get Counter (TEP - Task End Point) adress */ /*nrfx_timer_task_address_get - Function for returning the address of a specific timer task. Parameters [in] p_instance Pointer to the driver instance structure. [in] timer_task Timer task. Returns - Task address. (NRF_TIMER_TASK_COUNT = Task for incrementing the timer (in counter mode)) */ uint32_t counter_addr_pixel = nrfx_timer_task_address_get(&counter_pixel, NRF_TIMER_TASK_COUNT);