Revision: 1360
Author: [email protected]
Date: Mon Sep 28 16:41:33 2009
Log: add 18f ADC unittest
http://code.google.com/p/jallib/source/detail?r=1360

Added:
  /trunk/test/unittest/18f14k50_adc.jalt

=======================================
--- /dev/null
+++ /trunk/test/unittest/18f14k50_adc.jalt      Mon Sep 28 16:41:33 2009
@@ -0,0 +1,137 @@
+-- Title: unittest to check ADC libs for 18f14k50
+-- Author: Albert Faber, Copyright (c) 2009, all rights reserved.
+-- Adapted-by:
+-- Compiler: >=2.4l
+--
+-- This file is part of jallib (http://jallib.googlecode.com)
+-- Released under the BSD license  
(http://www.opensource.org/licenses/bsd-license.php)
+--
+-- Description: this describes multiple unittests (a testcase), to test the
+-- many different combination while setting up ADC.
+--
+-- Notes: see jallib wiki page about unit testing to learn how to use this  
file
+--
+
+;@jallib section pic
+include 18f14k50   ;@no_debug
+pragma target OSC HS
+pragma target clock 20_000_000
+pragma target WDT  disabled
+enable_digital_io()
+-- force analog pin/port to be output, so we can check they are
+-- automagically set as input when configured (else it can be optimized  
away)
+porta_direction = all_output
+portb_direction = all_output
+portc_direction = all_output
+
+
+;@jallib section self_test
+include unittest
+var byte a = 120
+test_byte(a)            ;@assertEquals 120 test_test
+
+
+;@jallib testcase test_all_analog_pins
+;@jallib use pic
+;@jallib use self_test
+const byte ADC_NVREF = 0
+const bit ADC_HIGH_RESOLUTION = false
+const word ADC_RSOURCE = 2_500
+porta_direction = all_output
+portb_direction = all_output
+portc_direction = all_output
+
+include adc
+adc_init()
+
+set_analog_pin(0)
+-- check pin on PORTA configured as inputs (not supported)
+asm nop
+test_byte(TRISA)  ;@assertEquals 0 test_porta_pin_an0_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an0_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 0 test_portb_pin_an0_input
+
+
+set_analog_pin(1)
+-- check pin on PORTA configured as inputs (not supported)
+asm nop
+test_byte(TRISA)  ;@assertEquals 0 test_porta_pin_an01_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an01_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 0 test_portb_pin_an01_input
+
+set_analog_pin(2)
+-- check pin on PORTA configured as inputs (not supported)
+asm nop
+test_byte(TRISA)  ;@assertEquals 0 test_porta_pin_an012_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an012_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 0 test_portb_pin_an012_input
+
+
+set_analog_pin(3)
+-- check pin on PORTA configured as inputs (0b_0001_0000 => RA{4})
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an0123_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an0123_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 0 test_portb_pin_an0123_input
+
+set_analog_pin(4)
+-- check pin on PORTC configured as inputs (0b_0000_0001 => RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an01234_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an01234_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 1 test_portb_pin_an01234_input
+
+set_analog_pin(5)
+-- check pin on PORTC configured as inputs (0b_0000_0011 => RC{1},RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an012345_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an012345_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 3 test_portb_pin_an012345_input
+
+set_analog_pin(6)
+-- check pin on PORTC configured as inputs (0b_0000_0111 =>  
RC{2},RC{1},RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an0123456_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an0123456_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 7 test_portb_pin_an0123456_input
+
+set_analog_pin(7)
+-- check pin on PORTC configured as inputs (0b_0000_1111 =>  
RC{3},RC{2},RC{1},RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an01234567_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an01234567_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 15 test_portb_pin_an01234567_input
+
+set_analog_pin(8)
+-- check pin on PORTC configured as inputs (0b_0100_1111 =>  
RC(6),RC{3},RC{2},RC{1},RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an012345678_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an012345678_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 79 test_portb_pin_an012345678_input
+
+set_analog_pin(9)
+-- check pin on PORTC configured as inputs (0b_1100_1111 =>  
RC{7},RC{6},RC{3},RC{2},RC{1},RC{0} )
+asm nop
+test_byte(TRISA)  ;@assertEquals 32 test_porta_pin_an0123456789_input
+asm nop
+test_byte(TRISB)  ;@assertEquals 0 test_portb_pin_an0123456789_input
+asm nop
+test_byte(TRISC)  ;@assertEquals 207 test_portb_pin_an0123456789_input

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jallib?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to