Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp@7:13ae8d34cc97, 2017-01-04 (annotated)
- Committer:
- JovanEps
- Date:
- Wed Jan 04 15:12:43 2017 +0000
- Revision:
- 7:13ae8d34cc97
- Parent:
- 6:64a3bea8be86
- Child:
- 8:3af851c7bb8d
Final version of bit-banging speed test 1.0
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| screamer | 0:005629fe3609 | 1 | #include "mbed.h" |
| JovanEps | 6:64a3bea8be86 | 2 | //******************************************************** |
| JovanEps | 6:64a3bea8be86 | 3 | //** Nucleo-144 Stm32F746 and Stm32F767 bitbanging ****** |
| JovanEps | 7:13ae8d34cc97 | 4 | //** Port setting and pattern generation ****** |
| JovanEps | 7:13ae8d34cc97 | 5 | //** Speed - Benchmark ****** |
| JovanEps | 7:13ae8d34cc97 | 6 | //** Jovan Ivković - 2016. ****** |
| JovanEps | 7:13ae8d34cc97 | 7 | //** JovanEps (jovan.eps@gmail.com). ****** |
| JovanEps | 6:64a3bea8be86 | 8 | //******************************************************** |
| JovanEps | 7:13ae8d34cc97 | 9 | |
| screamer | 0:005629fe3609 | 10 | DigitalOut myled(LED1); |
| JovanEps | 5:64511b302803 | 11 | DigitalOut PD7(PF_13); |
| JovanEps | 7:13ae8d34cc97 | 12 | DigitalOut PD5(PE_11); //introduce D5 pin-out it ping faster :) |
| JovanEps | 6:64a3bea8be86 | 13 | DigitalOut PD13(PA_5); //introduce D13 pin-out |
| JovanEps | 6:64a3bea8be86 | 14 | Serial pc(USBTX, USBRX); |
| JovanEps | 7:13ae8d34cc97 | 15 | Timer timer; |
| screamer | 0:005629fe3609 | 16 | |
| JovanEps | 7:13ae8d34cc97 | 17 | void Pinging() |
| JovanEps | 7:13ae8d34cc97 | 18 | { |
| JovanEps | 7:13ae8d34cc97 | 19 | int vreme = 0; |
| JovanEps | 7:13ae8d34cc97 | 20 | while(1) { |
| JovanEps | 7:13ae8d34cc97 | 21 | // Pattern and port setting speed benchmark |
| JovanEps | 7:13ae8d34cc97 | 22 | timer.start(); |
| JovanEps | 7:13ae8d34cc97 | 23 | vreme = timer.read_us(); |
| JovanEps | 7:13ae8d34cc97 | 24 | for(int ii=0, ii<99, ii+) { |
| JovanEps | 7:13ae8d34cc97 | 25 | PD5 = 1; // D5 go low 1 go LOW in next 74..75ns |
| JovanEps | 7:13ae8d34cc97 | 26 | PD5 = 1; // D5 go low 2 |
| JovanEps | 7:13ae8d34cc97 | 27 | PD5 = 1; // D5 go low 3 |
| JovanEps | 7:13ae8d34cc97 | 28 | PD5 = 0; // D5 go inv-high on SN74vhc14 - >1.6..2.4V < 1.75ns |
| JovanEps | 7:13ae8d34cc97 | 29 | PD5 = 1; // D5 go low 5 |
| JovanEps | 7:13ae8d34cc97 | 30 | PD5 = 1; // D5 go low 6 |
| JovanEps | 7:13ae8d34cc97 | 31 | PD5 = 1; // D5 go low 7 |
| JovanEps | 7:13ae8d34cc97 | 32 | PD5 = 1; // D5 go low 8 |
| JovanEps | 7:13ae8d34cc97 | 33 | PD5 = 1; // D5 go low 9 |
| JovanEps | 7:13ae8d34cc97 | 34 | PD5 = 1; // D5 go low 10 |
| JovanEps | 7:13ae8d34cc97 | 35 | } |
| JovanEps | 7:13ae8d34cc97 | 36 | vreme = timer.read_us() - vreme; |
| JovanEps | 7:13ae8d34cc97 | 37 | wait_us(0.2); |
| JovanEps | 7:13ae8d34cc97 | 38 | pc.printf("Circle time... %4.4f \n", ( float ) vreme / 1000 ); //1k sets of PD5 |
| JovanEps | 7:13ae8d34cc97 | 39 | pc.printf("\n\n"); |
| JovanEps | 7:13ae8d34cc97 | 40 | timer.stop(); |
| JovanEps | 7:13ae8d34cc97 | 41 | |
| JovanEps | 7:13ae8d34cc97 | 42 | /* // Alternative |
| JovanEps | 7:13ae8d34cc97 | 43 | while(1) { |
| JovanEps | 6:64a3bea8be86 | 44 | PD5 = 0; // D5 go low 1 |
| JovanEps | 6:64a3bea8be86 | 45 | PD5 = 0; // D5 go low 2 |
| JovanEps | 6:64a3bea8be86 | 46 | PD5 = 0; // D5 go low 3 |
| JovanEps | 7:13ae8d34cc97 | 47 | PD5 = 1; // D5 go inv-low on 74vhc14 - <0.6v..0.9V < 1.6ns |
| JovanEps | 6:64a3bea8be86 | 48 | PD5 = 0; // D5 go low 5 |
| JovanEps | 6:64a3bea8be86 | 49 | PD5 = 0; // D5 go low 6 |
| JovanEps | 6:64a3bea8be86 | 50 | PD5 = 0; // D5 go low 7 |
| JovanEps | 6:64a3bea8be86 | 51 | PD5 = 0; // D5 go low 8 |
| JovanEps | 6:64a3bea8be86 | 52 | PD5 = 0; // D5 go low 9 |
| JovanEps | 6:64a3bea8be86 | 53 | PD5 = 0; // D5 go low 10 |
| JovanEps | 7:13ae8d34cc97 | 54 | wait_us(0.3); |
| JovanEps | 7:13ae8d34cc97 | 55 | */ |
| JovanEps | 7:13ae8d34cc97 | 56 | //pc.printf("\n"); |
| JovanEps | 6:64a3bea8be86 | 57 | } |
| JovanEps | 7:13ae8d34cc97 | 58 | } |
| JovanEps | 7:13ae8d34cc97 | 59 | |
| JovanEps | 7:13ae8d34cc97 | 60 | int main() |
| JovanEps | 7:13ae8d34cc97 | 61 | { |
| JovanEps | 5:64511b302803 | 62 | myled = 1; // LED is ON - working |
| JovanEps | 6:64a3bea8be86 | 63 | pc.baud(115200); |
| JovanEps | 7:13ae8d34cc97 | 64 | //pc.baud(921600); // Max garanted UART/seriall speed |
| JovanEps | 7:13ae8d34cc97 | 65 | pc.printf("Starting...\n"); |
| JovanEps | 7:13ae8d34cc97 | 66 | wait(0.2); // 200 ms |
| JovanEps | 7:13ae8d34cc97 | 67 | |
| JovanEps | 7:13ae8d34cc97 | 68 | //NVIC_DisableIRQ(XXX); // Disable NVIC interrupt; |
| JovanEps | 7:13ae8d34cc97 | 69 | Pinging(); //Call of Pinging methode |
| JovanEps | 6:64a3bea8be86 | 70 | |
| JovanEps | 6:64a3bea8be86 | 71 | /* |
| screamer | 0:005629fe3609 | 72 | while(1) { |
| JovanEps | 7:13ae8d34cc97 | 73 | // PD7 = 1; // D7 go high in ~75ns |
| JovanEps | 7:13ae8d34cc97 | 74 | //PD13 = 1; // D13 go high has delay of |
| JovanEps | 6:64a3bea8be86 | 75 | // myled = 1; |
| JovanEps | 7:13ae8d34cc97 | 76 | |
| JovanEps | 6:64a3bea8be86 | 77 | PD5 = 0; // D5 go high |
| JovanEps | 6:64a3bea8be86 | 78 | //wait(0); // 1ns - exclude, we need as fast as we can get |
| JovanEps | 6:64a3bea8be86 | 79 | // PD7 = 0; // D7 go low in next 74ns |
| JovanEps | 7:13ae8d34cc97 | 80 | //PD13 = 0; // D13 go high |
| JovanEps | 6:64a3bea8be86 | 81 | // PD7 = 1; |
| JovanEps | 6:64a3bea8be86 | 82 | //PD13 = 1; // D13 go high |
| JovanEps | 6:64a3bea8be86 | 83 | PD5 = 0; |
| JovanEps | 6:64a3bea8be86 | 84 | // PD13 = 0; // D13 go high |
| JovanEps | 6:64a3bea8be86 | 85 | //myled = 0; |
| JovanEps | 6:64a3bea8be86 | 86 | PD5 = 0; // D5 go low |
| JovanEps | 6:64a3bea8be86 | 87 | PD5 = 1; // D5 go inv-high on 74vhc14 - 1v |
| JovanEps | 6:64a3bea8be86 | 88 | PD5 = 0; // D5 go low |
| JovanEps | 6:64a3bea8be86 | 89 | PD5 = 1; // D5 go inv-high on 74vhc14 -2v |
| JovanEps | 6:64a3bea8be86 | 90 | PD5 = 0; // D5 go low 2v |
| JovanEps | 6:64a3bea8be86 | 91 | PD5 = 1; // D5 go inv-high on 74vhc14 - 2v |
| JovanEps | 6:64a3bea8be86 | 92 | PD5 = 0; // D5 go low 2v |
| JovanEps | 6:64a3bea8be86 | 93 | PD5 = 1; // D5 go inv-high on 74vhc14 - 3v |
| JovanEps | 6:64a3bea8be86 | 94 | PD5 = 0; // D5 go low 3v |
| JovanEps | 6:64a3bea8be86 | 95 | //v4 111010101010101 4-low lead and 6-inv-peek |
| JovanEps | 6:64a3bea8be86 | 96 | PD5 = 1; // D5 go inv-high on 74vhc14 - 4v |
| JovanEps | 6:64a3bea8be86 | 97 | PD5 = 0; // D5 go low 4v |
| JovanEps | 6:64a3bea8be86 | 98 | PD5 = 1; // D5 go inv-high on 74vhc14 - 4v |
| JovanEps | 6:64a3bea8be86 | 99 | PD5 = 0; // D5 go low 4v |
| JovanEps | 6:64a3bea8be86 | 100 | //wait(0);// 1nsec - exclude, we need as fast as we can get |
| JovanEps | 7:13ae8d34cc97 | 101 | |
| JovanEps | 7:13ae8d34cc97 | 102 | } |
| JovanEps | 7:13ae8d34cc97 | 103 | */ |
| screamer | 0:005629fe3609 | 104 | } |