Improve bpsk test transmission timing
This commit is contained in:
		
							parent
							
								
									eb75e3ccc3
								
							
						
					
					
						commit
						2825e5e49d
					
				
					 1 changed files with 14 additions and 3 deletions
				
			
		
							
								
								
									
										17
									
								
								src/main.c
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								src/main.c
									
									
									
									
									
								
							|  | @ -947,10 +947,21 @@ static void command(const char *cmd) | |||
| 				actual = rx_lo_init(actual - step_hz); | ||||
| 				printf("Frequency: %.0f\n", actual); | ||||
| 			} else if ((c >= '1') && (c <= '9')) { | ||||
| 				for (int i = 0; i < 1000; i++) { | ||||
| 					phase = !phase; | ||||
| 				uint32_t t0 = time_us_32(); | ||||
| 				uint32_t tmax = 1000000 / (c - '0'); | ||||
| 				uint32_t step = 1000 / (c - '0') / 2; | ||||
| 
 | ||||
| 				while (true) { | ||||
| 					uint32_t t1 = time_us_32(); | ||||
| 					uint32_t te = t1 - t0; | ||||
| 
 | ||||
| 					if (te >= tmax) | ||||
| 						break; | ||||
| 
 | ||||
| 					phase = (te / step) & 1; | ||||
| 
 | ||||
| 					gpio_set_outover(n, phase); | ||||
| 					sleep_us(1000 / (c - '0')); | ||||
| 					sleep_us(1); | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue