Jump to content
43oh

Launchpad video oscilloscope


Recommended Posts

15.7 ksps WOW!

16.6 ms sweep Amazing!

Special limited time offer - only $4.30!

Order now. Operators are standing by.

 

 

       .cdecls C, LIST, "msp430g2231.h"

       .text
       .global _main

       .bss    sync_state, 2
       .bss    sync_lines, 2
       .bss    video_state, 2
       .bss    vid_line, 2


_main                                   ;
       mov     #WDTPW | WDTHOLD, &WDTCTL ; No watchdog
                                       ;
       mov     #XT2OFF + 15, &BCSCTL1  ; DCO 16 Mhz
       mov     #0x86, &DCOCTL          ;
                                       ;
       mov     #0x0280, SP             ; Stack pointer
                                       ;                                       
       mov.b   #0xF0, &P1DIR           ; I/O assignment
       mov.b   #0x50, &P1SEL           ; Enable Timer A output, SMCLK output
       clr.b   &P1REN                  ;
       clr.b   &P1OUT                  ;
                                       ;
       mov     #0x0002, &ADC10AE0      ; Analog in on P1.1 (A1)
       mov     #0x1000, &ADC10CTL1     ; Select A1
                                       ; Configure ADC
       mov     #ADC10SHT_0 | ADC10SR | ADC10ON | ENC, &ADC10CTL0
                                       ;
       call    #video_init             ; Begin video
                                       ;                                       
       jmp     $                       ;
                                       ;
video_init                              ; --- Initialize Video Generation ---
       clr     &sync_state             ; Init state machine
       mov     #1, sync_lines          ; 
       clr     &video_state            ;
       mov     #1016, &TACCR0          ; Setup Timer A period for 63.5 us
       mov     #75, &TACCR1            ; Setup Timer A compare for video sync
       mov     #0x0210, &TACTL         ; Timer A config: SMCLK, count up
       mov     #0x0060, &TACCTL1       ; Setup Timer A set/reset output mode
       bis     #0x0010, &TACCTL0       ; Enable PWM interupt
       eint                            ; Enable interupts
       ret                             ;
                                       ;
video_isr                               ; --- Video ISR ---
       dec     &sync_lines             ; Decrement sync lines
       jne     vid_state               ; Skip sync if not zero...
       add     &sync_state, PC         ; Jump to sync handler...
                                       ; - Field 1/3
       jmp     vid_eq                  ; Pre Equalizing 
       jmp     vid_vsync               ; Vertical Sync
       jmp     vid_eq                  ; Post Equalizing
       jmp     vid_vbi                 ; VBI
       jmp     vid_active              ; Active Video
       jmp     vid_half                ; Video half line
                                       ; - Field 2/4
       jmp     vid_eq                  ; Pre Equalizing
       jmp     vid_vsync               ; Vertical Sync
       jmp     vid_eq                  ; Post Equalizing
       jmp     vid_half                ; Video half line
       jmp     vid_vbi                 ; VBI
       jmp     vid_active              ; Active Video
       clr     &sync_state             ; Reset sync state
       ;jmp    vid_eq                  ; Same as first state
                                       ;       
vid_eq                                  ; Equalizing pulses - 6 half lines
       mov     #508, &TACCR0           ; Half line
       mov     #38, &TACCR1            ; Equalizing pulse duration
       mov     #6, &sync_lines         ; 6 half lines
       clr     &video_state            ; No video generation during sync
       incd    &sync_state             ; Next state
       reti                            ;
                                       ;                                       
vid_vsync                               ; Vertical sync - 6 half lines
       mov     #508 - 75, &TACCR1      ; Sync pulse duration
       mov     #6, &sync_lines         ; 6 half lines
       incd    &sync_state             ; Next state
       reti                            ;
                                       ;
vid_half                                ; Video half line - 1 half line
       mov     #508, &TACCR0           ; Half line
       mov     #75, &TACCR1            ; Sync pulse duration
       mov     #1, &sync_lines         ; 1 half line
       incd    &sync_state             ; Next state
       clr     &video_state            ; No video generation during half line and sync
       reti                            ;
                                       ;
vid_vbi                                 ; Vertical blanking interval - 11 lines
       mov     #1016, &TACCR0          ; Full line
       mov     #75, &TACCR1            ; Sync pulse duration
       mov     #11, &sync_lines        ; 11 lines
       incd    &sync_state             ; Next state
       reti                            ;
                                       ;
vid_active                              ; Active video - 242 lines
       mov     #242, &sync_lines       ; 242 lines
       incd    &sync_state             ; Next state
       mov     #2, &video_state        ; Generate video
       clr     &vid_line               ; Clear video line count
       jmp     vid_field               ; Generate video...
                                       ;
vid_blank_9                             ; 9 blank lines
       mov     #9, &sync_lines         ;
       incd    &sync_state             ;
       clr     &video_state            ;
       reti                            ;
                                       ;
vid_state                               ; -- Active Video Generation
       add     &video_state, PC        ;
       reti                            ; No active video
       ;jmp    vid_field               ; Field
                                       ;       
vid_field                               ;
       push    R12                     ;
                                       ;
       mov     &TAR, R12               ;
       cmp     #160, R12               ;
       jlo     $ - 8                   ;
       and     #7, R12                 ;
       rla     R12                     ;
       add     R12, PC                 ;
       nop                             ;
       nop                             ;
       nop                             ;
       nop                             ;
       nop                             ;
       nop                             ;
       nop                             ;
                                       ;
       mov     &ADC10MEM, R12          ; Get ADC results
       bis     #ADC10SC, &ADC10CTL0    ; Start new conversion
                                       ;
       cmp     #750, R12               ; Limit upper ADC value
       jlo     inrange                 ;
       mov     #750 - 2, R12           ;
                                       ;   
inrange sub     #4, R12                 ; Subtract four w/ four cycles per iteration
       nop                             ;
       jc      $ - 4                   ;
       inv     R12                     ; Negate the remainder
       rla     R12                     ; Multiply by two
       add     R12, PC                 ; One cycle granularity computed jump
       nop                             ;
       nop                             ;
       nop                             ;
                                       ;
       bis.b   #0x80, &P1OUT           ;
       bic.b   #0x80, &P1OUT           ;
                                       ;
       pop     R12                     ;
                                       ;
       reti                            ;
                                       ;
                                       ; Interrupt Vectors
       .sect   ".reset"                ;
       .short  _main                   ;                                       
       .sect   ".int09"                ; TACCR0 CCIFG
       .short  video_isr               ;
                                       ;
       .end                            ;

Link to post
Share on other sites
... The small flash and RAM is much more limiting than the speed.

 

I hear ya. While 2 kB on the '2231 might sound like a lot, it's really only 1 kWord. And if you can achieve an average of two words per instruction, then you're really only talking about 500 instructions. Yikes!

 

BTW, thank you for all the great examples you've been posting. It's been an incredible education.

 

Cheerful regards, Mike

Link to post
Share on other sites

Yeah, I'm feeling inadequate now. :oops:

 

My stuff is just simple stuff written in slow-pokey old C. :roll:

 

I feel like I'm driving a rusty old 59 Cadillac and oPossum is taunting me while driving his pimped out Rice Rocket.

Link to post
Share on other sites

Yeah, I'm feeling inadequate now. :oops:

 

My stuff is just simple stuff written in slow-pokey old C. :roll:

 

I feel like I'm driving a rusty old 59 Cadillac and oPossum is taunting me while driving his pimped out Rice Rocket.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...